3,245
社区成员
发帖
与我相关
我的任务
分享
bool create_succ = false;
CoInitialize(NULL);
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_ALL, IID_IShellLinkA, (void**)&pShellLink);
if (SUCCEEDED(hres))
{
pShellLink->SetPath(target_path);
IPersistFile *pPersistFile;
hres = pShellLink->QueryInterface(IID_IPersistFile, (void**)&pPersistFile);
if (SUCCEEDED(hres))
{
hres = pPersistFile->Save(link_file, TRUE);
if (SUCCEEDED(hres))
{
create_succ = true;
}
pPersistFile->Release();
}
pShellLink->Release();
}
CoUninitialize();
// Sleep(1000); // 加上这句就能成功
if (create_succ)
{
CopyFile(link_file, dest);
}