|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
CoCreateInstance Fails in Windows XP
I am calling CoCreateInstance to create a shortcut in Windows using C++. My program compiles find, but when I run it in XP, it encounters an error and closes. I run it in Compatability Mode in Windows 98/ME and it works just fine. What do I need to do to make it compatable with XP?
|
|
#2
|
|||
|
|||
|
What error do you get when you run it in XP?
|
|
#3
|
|||
|
|||
|
The error message is:
"My Program has encountered a problem and needs to close. We are sorry for the inconvenience." It allows you to debug, send an error report, or don't send an error report. |
|
#4
|
|||
|
|||
|
Do you know whether CoCreateInstance itself succeeds, do you test the return value? Have you been able to determine what point your program gets to before you get the error?
|
|
#5
|
|||
|
|||
|
It fails when I try to use the pointer to set a path for my shortcut. The pointer equals NULL. Here's my code:
IShellLink* psl; hres=CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl ); if (!SUCCEEDED(hres) || psl==NULL) { CoUninitialize(); } IPersistFile* ppf; psl->SetPath("C:\\Program Files\\My Program\\program.exe"); psl->SetDescription("Launch Program"); psl->SetIconLocation("C:\\Program Files\\My Program\\program.exe", 0); psl->QueryInterface(IID_IPersistFile,(LPVOID*)&ppf); ppf->Save(wLinkPath, FALSE); ppf->Release(); CoUninitialize(); |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > CoCreateInstance Fails in Windows XP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|