VC获取快捷方式的文件路径

bool ReadShortcut(LPWSTR lpwLnkFile, LPSTR lpDescFile)
{
bool bReturn = true;
IShellLink *pShellLink;
if(bReturn)
{
bReturn = (CoInitialize(NULL) == S_OK);
if(bReturn)
{
bReturn = CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (void **)&pShellLink) >= 0;
if(bReturn)
{
IPersistFile *ppf;
bReturn = pShellLink->QueryInterface(IID_IPersistFile, (void **)&ppf) >= 0;
if(bReturn)
{
bReturn = ppf->Load(lpwLnkFile, TRUE) >= 0;
if(bReturn)
{
pShellLink->GetPath(lpDescFile, MAX_PATH, NULL, 0);
}
ppf->Release ();
}
pShellLink->Release ();
}
CoUninitialize();
}
}
return bReturn;
}
// 测试代码:
char szBuf[MAX_PATH];
ReadShortcut(L”C://GLWorld.lnk”, szBuf);
MessageBox(0, szBuf, “”, 0);

转载请说明出处:http://blog.csdn.net/mycaibo

你可能感兴趣的:(server,测试,null,Path)