Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

doctorsixstring

Creating shortcuts

This topic is 5912 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
That''s not what I meant. I want to actually create a *.lnk file (a windows shortcut file) in a specified directory from within my code. I don''t want to simply launch an executable.

I have looked at IShellLink, and it looks like it might be the only available tool. O therwise I might have to right an entire .lnk file out myself as a binary file.

If anyone has any info on making this task easier, please let me know.

-Mike

Share this post


Link to post
Share on other sites
From CPT:

  
int CPT_SystemLinkSpawn(const char *Link, const char *File) {
HRESULT Result;
IShellLink *PSL;
IPersistFile *PPF;
char *LinkExt;
WORD WSZ[CPT_SYSTEM_PATHMAX];

CoInitialize(NULL);

Result = CoCreateInstance(&CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, &IID_IShellLink, (void **) &PSL);

if(SUCCEEDED(Result)) {
PSL->lpVtbl->SetPath(PSL,File);
PSL->lpVtbl->SetDescription(PSL,"");

Result = PSL->lpVtbl->QueryInterface(PSL, &IID_IPersistFile, (void **) &PPF);
if(SUCCEEDED(Result)) {
LinkExt = (char *) malloc(sizeof(char) * (strlen(Link) + 5));
if(LinkExt == NULL) {
PSL->lpVtbl->Release(PSL);
CoUninitialize();
return -3;
}

strcpy(LinkExt,Link);
strcat(LinkExt,"
.lnk");

MultiByteToWideChar(CP_ACP, 0, LinkExt, -1, WSZ, CPT_SYSTEM_PATHMAX);

Result = PPF->lpVtbl->Save(PPF, WSZ, TRUE);
PPF->lpVtbl->Release(PPF);

free(LinkExt);
} else return -2;
PSL->lpVtbl->Release(PSL);
} else return -1;

CoUninitialize();

return 0;
}



Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!