|
Email me a release to test please Shog,
It might be Bill's 2000 has a problem.
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
More about me
|
|
|
|
|
It ONLY works only Windows 98 and I was surprised to learn this as you are!
If you set _UNICODE, and compile it under UNICODE, as a SEPARATE exe or DLL then it works ONLY on Windows 98.
So far, nobody has created a class or piece of code that will compile and create a SINGLE exe or DLL that works on BOTH Windows 98 and Windows 2000.
Bill SerGio, The Infomercial King
|
|
|
|
|
Please excuse my type...
i meant...
If you set _UNICODE, and compile it under UNICODE, as a SEPARATE exe or DLL then it works ONLY on WINDOWS 2000.
Bill SerGio, The Infomercial King
|
|
|
|
|
I'm confused,
Shog9's app work on my Win 2000 and 98 for me.
Have you mangled your 2000 ?
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
More about me
|
|
|
|
|
I have looked at every sample of source code i could find on creating Links on the Desktop and EVERY piece of sample code FAILS to create links on Windows 2000--except for those samples that include a separate UNICODE version of the code.
Now it is VERY inconvenient to have to include 2 versions of a program, one in ASCII and another in UNICODE. So what's the answer?
I will offer 2 solutions to this problem that I originally proposed in the "Lounge" where I was told was the wrong place to post anything important or serious!
The first solution is to create 2 versions of your code, and include BOTH versions as a resource in your application and launch the correction version from your program based on the Windows Platform. This works but is not elegant at all--it is the solution that i believe is used by BOTH InstallShield and WYSE Installers! No wonder their exe files are so big!
The other solution I offer below. I believe it will work if compiled on Windows 2000. And it would be nice if someone with Windows 2000 could let me know if it works?
I develop on Windows 98 using Visual Studio 6...
#include "direct.h" /* This is needed for _mkdir */
#include "objbase.h"
#include "shlguid.h"
#include "wchar.h"
#define INITGUID
#include "initguid.h"
//#define INC_OLE2
//#pragma comment( lib , "OLE2")
//#include "ole2.h"
//#include "comcat.h"
//#include "olectl.h"
Where UINT uLinkLoc = CSIDL_DESKTOP;
Is there a way to write a SINGLE class that can create a link on the Desktop in both Windows 98 and Windows 2000 without compiling 2 separate versions(one UNICODE and one ASCII)???
bool CInstall::CreateShortCut( LPCSTR lpszSourceFile,
LPCSTR lpszSourceDir,
UINT uLinkLoc,
LPCSTR lpszDesc,
bool IsFolder )
{
HRESULT hResult = NULL;
IShellLink* pShellLink = NULL;
bool rc = false;
LPCSTR lpszDestination = NULL;
ITEMIDLIST *id = NULL;
TCHAR szLinkLoc[MAX_PATH] = "";
TCHAR szShellPath[MAX_PATH] = "";
CString sLinkLoc;
sLinkLoc.Empty();
CString sLink;
sLink.Empty();
// Initialize IShellLink interface
hResult = CoInitialize(NULL);
// Get pointer to IShellLink Interface
hResult = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, IID_IShellLink,
(void**) &pShellLink);
if (SUCCEEDED(hResult))
{
//Cache, Fonts, History, NetHood, Personal, Printhood, Programs,
// Recent, SendTo, Start Menu, Startup, Templates, ShellNew
if (uLinkLoc == CSIDL_APPDATA) {
sLinkLoc = "AppData";
} else if (uLinkLoc == CSIDL_COOKIES) {
sLinkLoc = "Cookies";
} else if (uLinkLoc == CSIDL_DESKTOP) {
sLinkLoc = "Desktop";
} else if (uLinkLoc == CSIDL_STARTMENU) {
sLinkLoc = "Start Menu";
} else if (uLinkLoc == CSIDL_STARTUP) {
sLinkLoc = "Startup";
} else if (uLinkLoc == CSIDL_FAVORITES) {
sLinkLoc = "Favorites";
}
if (sLinkLoc.GetLength()>0) {
GetShellFolderPath(sLinkLoc, szShellPath);
sLink = szShellPath;
} else {
SHGetSpecialFolderLocation(NULL, uLinkLoc, &id);
SHGetPathFromIDList(id, szLinkLoc);
sLink = szLinkLoc;
}
sLink += "\\";
sLink += lpszDesc;
sLink += ".lnk";
lpszDestination = (LPCSTR)sLink;
if (IsFolder) {
// Requies: #Include
hResult = _mkdir(lpszDestination);
// Clean up
pShellLink->Release();
CoUninitialize();
if (SUCCEEDED(hResult)) { return true; } else { return false; }
}
IPersistFile* ppf = NULL;
// Set path to shortcut target
pShellLink->SetPath(lpszSourceFile);
// Add Start Directory
if(lpszSourceDir)
hResult = pShellLink->SetWorkingDirectory(lpszSourceDir);
// Add Description
if(lpszDesc)
hResult = pShellLink->SetDescription(lpszDesc);
//if(lpszArguments) { hResult = pShellLink->SetArguments(lpszArguments); }
//if (lpszIconLocation) { hResult = pShellLink->SetIconLocation(lpszIconLocation, nIconIndex); }
//if (Show != -1) { hResult = pShellLink->SetShowCmd(Show); }
//if (HotKey != 0) { hResult = pShellLink->SetHotkey(HotKey); }
//if(nIconIndex!=(UINT)-1) { hResult = pShellLink->SetIconLocation(lpszSourceFile,nIconIndex); }
// Query IShellLink for IPersistFile interface
// for saving shortcut in persistent storage
hResult = pShellLink->QueryInterface(IID_IPersistFile, (void**) &ppf);
if (SUCCEEDED(hResult)) {
WORD wszWideString[_MAX_PATH+1];
// Ensure that string is ANSI
//MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,szLink,-1,wsz,sizeof(wsz));
MultiByteToWideChar(CP_ACP, 0, lpszDestination, -1, wszWideString, _MAX_PATH+1);
// Save link by calling IPersistFile::Save.
hResult = ppf->Save(wszWideString, TRUE);
ppf->Release();
rc = true;
SHChangeNotify(SHCNE_ALLEVENTS, SHCNF_IDLIST, &pShellLink, 0);
}
// Clean up
pShellLink->Release();
CoUninitialize();
}
return rc;
}
Bill SerGio, The Infomercial King
|
|
|
|
|
I forgot to include one of the functions that I call in the code sample above and I am including it below.
bool CInstall::GetShellFolderPath(LPCSTR lpShellFolder, LPSTR lpShellPath)
{
//lpShellFolder can be one of the following
//AppData, Cache, Cookies, Desktop, Favorites, Fonts, History, NetHood,
//Personal, Printhood, Programs, Recent, SendTo, Start Menu, Startup,
//Templates, ShellNew
DWORD rc;
DWORD length = MAX_PATH;
DWORD type = REG_SZ;
HKEY hkey;
rc = RegOpenKeyEx(HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
0,
KEY_READ,
&hkey);
if (rc == ERROR_SUCCESS)
{
rc = RegQueryValueEx(hkey,
lpShellFolder,
NULL,
&type,
(BYTE *) lpShellPath,
&length);
RegCloseKey(hkey);
}
if (rc == ERROR_SUCCESS)
return true;
else
return false;
}
Bill SerGio, The Infomercial King
|
|
|
|
|
Have not tested, but if you say a UNICODE build will work
it is maybe because there are 2 IShellLink interfaces, one
IShellLinkA and one IShellLinkW, and if that happens to be
the case you could build an ANSI app and use IShellLinkW and get
it to work
|
|
|
|
|
So if this is the case, then:
if (b2000 || bNT) {
// Call "IShellLinkW"
}
else {
// Call "IShellLinkA"
}
Is this what you had in mind to build 2 versions in one class?
What I don't understand is why hasn't anyone posted a sample of this code before?
Bill SerGio, The Infomercial King
|
|
|
|
|
I was thinking, just query for IShellLinkW, if you get it, use it.
Otherwise use IShellLinkA.
|
|
|
|
|
Anyone know ehre to get some ASPI documentation?
Thanks in advance.
|
|
|
|
|
|
I was just wondering if there was a way to turn on and off the keyboard lights for CapsLock, NumLock and ScrollLock programmatically.
any help appreciated
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it" Nish on life [methinks]
"It's The Soapbox; topics are optional" Shog 9
|
|
|
|
|
What! Brian Delahunty is asking a programming question
Look here. Clickety
I have never wasted time worrying about such insignificant things. Keep your eye upon the donut and NOT upon the hole. - Bill Sergio in The Lounge - June 23, 2002
|
|
|
|
|
Thanks I should have known that!!!!!!!!!
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it" Nish on life [methinks]
"It's The Soapbox; topics are optional" Shog 9
|
|
|
|
|
How can I get the style of a window class.
Ex: I have a window (handle=0x00000b94, class name=#32770(dialog) )
I want to get the styles and extended styles of it as CS_DBLCLKS, WS_EX_CLIENTEDGE....
How can I do that ?
I try this way:
LONG lStyles=::GetWindowLong(hwnd,GWL_STYLE);
LONG lExStyles=::GetWindowLong(hwnd,GWL_EXSTYLE);
CString strStyles;
if ((lStyles&BS_OWNERDRAW)==BS_OWNERDRAW)
strStyles+="BS_OWNERDRAW";
if ((lStyles&CS_VREDDRAW)==CS_VREDDRAW)
strStyles+="CS_VREDDRAW";
...
...
(hundreds of "if" !!!!!!!!!!!!!!!)
Help me !
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
dlhson wrote:
extended styles of it as CS_DBLCLKS, WS_EX_CLIENTEDGE
First off the CS_DBLCLKS is a CLASS style, not a window style
the GetWindowLong, using the GWL_STYLE or GWL_EXSTYLE will only return you the window styles (i.e. WS_XXX ,or WS_EX_XXX)
for CS_XXX you need to call GetClassLong( hwnd, GCL_STYLE )
As far as conmverting them to a string, I think you are stuck with a big if/else statement, sorry !
|
|
|
|
|
Dear All,
how can i solve the problem of including the View class header file in the MainFrame.cpp file. when do so an error occure about the GetDocument(); declaration in the view header file.the error says "error C2143: syntax error : missing ';' before '*'"
thanks,
Mohammad Zakarni
|
|
|
|
|
You need to include the document class as well. The error is because GetDocument returns a pointer to a document object, so you need to include it first, so it knows what that is.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Cool thank you it worked...
Thanx;)
|
|
|
|
|
I got the same error C2143 when I moved a snippet of working code to open a file and load a list box. I put the code in a new file as a good programming practice and I think the error was related to the include header:
#include <fstream>
using namespace std;
Any suggestions?
When you come to a fork in the road, take it! Y. Berra
|
|
|
|
|
doubl00 wrote:
#include
using namespace std;
Any suggestions?
1. Check 'display this message as is' or use < and > to do < >
2. NEVER use all of namespace std.
3. I really don't know, because I don't know what you included. The problem will be different now, because it's obviously std library stuff you're using. Could you post the offending code and the name of the header ?
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
When i edit my menu in the resource editor it is OK, but when i start the app, it is
disabled, and i cannot enable it, i tried with handling WM_INITMENU, and enabling the
items there but no success. Only E&xit it OK, it is the only menu item that works,
why is that ?
And another question... Is there any significance which class will contain the menu's
ON_COMMAND handlers ?
|
|
|
|
|
if you are using MFC the menu handler will need to be in a class that has an instance available ..... if you have the menu handler in a doc class that has no open document...then MFC will disable the menu item for you...since there is no handler available to service the request.....if that is not the case, give a little more detailed info.....about the problem
1. The Lord loves a workin' man.
2. See a doctor and get rid of it.
3. Don't trust whitey.
|
|
|
|
|
I am Korean and weak English.
I want fax brodcasting service. But I don't know how to use below three API.
I want to know how to working together three below API.
FaxSendDocumentForBroadcast()
FaxCompleteJobParams()
FAX_RECIPIENT_CALLBACK()
Please help me. I searched MSDN and web site.
But there no detail data about FaxSendDocumentForBroadcast().
I attach my fax broadcast project source code.
Thank you very much.
BOOL CALLBACK CALLBACK FAX_RECIPIENT_CALLBACK(
HANDLE FaxHandle, //handle to the fax server
DWORD RecipientNumber, //index indicating current fax recipient
LPVOID Context, //pointer to context information
PFAX_JOB_PARAM pfxParam, // [in,out] pointer to job information structure
PFAX_COVERPAGE_INFO pcpInfo ) // [in,out] pointer to local cover page structure
{
pfxParam->SizeOfStruct = sizeof(FAX_JOB_PARAM);
pfxParam->RecipientNumber = pszFaxNumber; // recipient's fax numbe
pfxParam->ScheduleAction = JSA_NOW; //schedule the transmission at any time in the next 24 hours
if(RecipientNumber > 10) return FALSE;
else return TRUE;
}
void CFaxClientDlg::SendFax()
{
if(!FaxConnectFaxServer(NULL, &fxHandle))
{
DWORD dwError = ::GetLastError();
switch(dwError){
case ERROR_INVALID_PARAMETER:
break;
case ERROR_NOT_ENOUGH_MEMORY:
break;
}
ReportOSError();
FaxClose(fxHandle);
return;
}
/*
if(!FaxCompleteJobParams( &pfxParam, &pcpInfo ) )
{
ReportOSError();
FaxClose(fxHandle);
return;
}
*/
if( FaxSendDocumentForBroadcast(fxHandle, pszFileName, &dwJobId, FAX_RECIPIENT_CALLBACK, NULL) ) /* [out] dwJobId */
AfxMessageBox("SendDoc Succeeded");
else ReportOSError();
// Cleanup here
FaxFreeBuffer(pfxParam);
if ( pcpInfo )
FaxFreeBuffer(pcpInfo);
FaxClose(fxHandle);
}
|
|
|
|
|
you didn't find indo on MSDN on this because, (I believe), this is not part of the OS API, Windows has traditionally never provided fax support....this is probably a 3rd party lib, you need to consult the vendor documentation....if Windows is now supporting Fax thru API then it is a new one on me, wouldn't be the first time though!!!!
1. The Lord loves a workin' man.
2. See a doctor and get rid of it.
3. Don't trust whitey.
|
|
|
|
|