How to create command line shortcut with shell api?
Hi,
I want to create a shortcut with shell API. But when I double clicked the
shortcut, windows prompt "Can't find default.htm, perhaps it was removed."
I can make sure the path is correct. And after I made some very small change
to the short, such as add a space in start location, the shortcut worked
properly. How to fix my code ? Thanks in advanced.
Here is my code:
IShellLink* psl;
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (LPVOID*)&psl);
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
psl->SetPath("\"C:\Program Files\Internet Explorer\iexplore.exe\"
d:\\webpos\\default.htm");
psl->SetWorkingDirectory("D:\\webpos");
psl->SetDescription(cpDesc);
hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
if (SUCCEEDED(hres))
{
char cpDesktop[MAX_PATH] = {0};
SHGetSpecialFolderPath(NULL, cpDesktop, CSIDL_DESKTOPDIRECTORY,
FALSE);
_bstr_t bstrLnk(cpDesktop);
bstrLnk += "\\";
bstrLnk += szLnkName;
hres = ppf->Save(bstrLnk, TRUE);
ppf->Release();
}
psl->Release();
}