How to create a Shortcut File by programming in C++?

  • Thread starter Thread starter Ping
  • Start date Start date
P

Ping

Hi, All,

How to create a Shortcut File by programming in C++?
To use whitch function or Windows API?

Thinks.
 
Hello Will,

I try the example for creating the shortcut file. but the following function
return fail.
Can you tell me the reason?

hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER,IID_IShellLink, (LPVOID*)&psl);

Thanks
 
Ping said:
I try the example for creating the shortcut file. but the following
function return fail.
Can you tell me the reason?

hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER,IID_IShellLink, (LPVOID*)&psl);

Here is a tip for some self-help: take a look at the value of hres in the
watch window. Then plug that value into the error lookup tool from the menu
to see the text of the message.

Did you remember to call CoInitialize[Ex]()?

Regards,
Will
 
Hi Will,

Yes, i'm missing to call CoInitializeEx(...).
Now it's OK!

Thank you very much

William DePalo said:
Ping said:
I try the example for creating the shortcut file. but the following
function return fail.
Can you tell me the reason?

hres = CoCreateInstance(CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER,IID_IShellLink, (LPVOID*)&psl);

Here is a tip for some self-help: take a look at the value of hres in the
watch window. Then plug that value into the error lookup tool from the
menu to see the text of the message.

Did you remember to call CoInitialize[Ex]()?

Regards,
Will
 
Back
Top