#include <shlobj.h> bool ReadShortcut(LPWSTR lpwLnkFile, LPWSTR 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; } int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { WCHAR sz[MAX_PATH * 2]; ReadShortcut(L"C:\\Users\\Luck\\Desktop\\Autodesk 3ds Max 2009 32 位.lnk", sz); return 1; }
发表评论