I'm trying to create shortcut to folder programmatically as it would be by right-clicking on a folder->create short cut
I'm doing it using
IShellLink* pShellLink;
IPersistFile* pPersistFile;
//........
hRes = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
(LPVOID*)&pShellLink);
//.....
hRes = pShellLink->SetPath(pszTargetfile);
hRes = pShellLink->SetArguments(pszTargetargs);
if (wcslen(pszDescription) > 0)
{
hRes = pShellLink->SetDescription(pszDescription);
}
if (wcslen(pszCurdir) > 0)
{
hRes = pShellLink->SetWorkingDirectory(pszCurdir);
}
if (wcslen(pszIconfile) > 0 && iIconindex >= 0)
{
hRes = pShellLink->SetIconLocation(pszIconfile, iIconindex);
}
hRes = pShellLink->QueryInterface(IID_IPersistFile, (LPVOID*)&pPersistFile);
if (SUCCEEDED(hRes))
{
wcscpy_s(wszLinkfile, pszLinkfile);
hRes = pPersistFile->Save(wszLinkfile, TRUE);
pPersistFile->Release();
}
pShellLink->Release();
//....
After that I get XXX.lnk file. Then I double click it and see the window "Open With" instead of redirecting to the destinaiton folder. I found in my lnk properties that the target type is set to 'File' instead of 'File folder' (as in the case of creating a shortcut manually)
It should work as symlink but I need it to be a shortcut (so I don't use CreateSymbolicLink)
How to do it properly?
IShellLink::SetPathorIShellLink::SetIDList.