1

フォルダーを右クリックして、プログラムでフォルダーへのショートカットを作成しようとしています->ショートカットの作成

を使ってやっています

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 ファイルを取得します。次に、それをダブルクリックすると、宛先フォルダーにリダイレクトする代わりに、「開く」ウィンドウが表示されます。lnk プロパティで、ターゲット タイプが「ファイル フォルダ」ではなく「ファイル」に設定されていることがわかりました (ショートカットを手動で作成する場合と同様)。

シンボリックリンクとして機能するはずですが、ショートカットにする必要があります(したがって、CreateSymbolicLinkは使用しません)

適切に行う方法は?

4

1 に答える 1

1

私は理解しました-宛先パスのスラッシュは逆でなければなりません

于 2013-10-29T11:58:15.337 に答える