2013-10-29 75 views
1

我试图创建快捷方式以编程文件夹,因为它是通过在文件夹 - 右键单击​​>创建快捷方式在Windows上创建文件夹快捷方式程序

我用做

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(); 
//.... 

之后,我得到XXX.lnk文件。然后我双击它并看到“Open With”窗口而不是重定向到destinaiton文件夹。 我的目标类型设置为“文件”,而不是“文件夹”(如手动创建一个快捷方式的情况下)我LNK属性中找到

它应该工作作为符号链接,但我需要的是一个快捷方式(所以我不用CreateSymbolicLink

如何正确地做到这一点?

+1

你似乎并没有被设置链接的目标 - 你需要调用'::的IShellLink或SetPath''::的IShellLink SetIDList' 。 –

+0

@Jonathan Potter我使用SetPath(我更新了代码),但是如何使用SetIDList? – amplifier

回答

1

我想通了 - 在目标路径斜杠必须是落后

相关问题