June 20th, 2003, 06:16 PM
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?
June 21st, 2003, 06:46 AM
What error do you get when you run it in XP?
June 21st, 2003, 09:17 PM
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.
June 22nd, 2003, 04:56 AM
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?
June 22nd, 2003, 07:18 PM
It fails when I try to use the pointer to set a path for my shortcut. The pointer equals NULL. Here's my code:
if (!SUCCEEDED(hres) || psl==NULL)
psl->SetPath("C:\\Program Files\\My Program\\program.exe");
psl->SetIconLocation("C:\\Program Files\\My Program\\program.exe", 0);