12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #include "main.h"
- #include "../nu/ns_wc.h"
- extern "C"
- {
- HRESULT ResolveShortCut(HWND hwnd, LPCWSTR pszShortcutFile, LPWSTR pszPath)
- {
- IShellLinkW *psl = 0;
- WIN32_FIND_DATAW wfd = {0};
- *pszPath = 0;
- HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (void **) & psl);
- if (SUCCEEDED(hres))
- {
- IPersistFile *ppf = 0;
- hres = psl->QueryInterface(IID_IPersistFile, (void **) &ppf);
- if (SUCCEEDED(hres))
- {
- hres = ppf->Load(pszShortcutFile, STGM_READ);
- if (SUCCEEDED(hres))
- {
- hres = psl->Resolve(hwnd, SLR_ANY_MATCH);
- if (SUCCEEDED(hres))
- {
- wchar_t szGotPath[MAX_PATH] = {0};
- StringCchCopyW(szGotPath, MAX_PATH, pszShortcutFile);
- hres = psl->GetPath(szGotPath, MAX_PATH, & wfd,
- SLGP_SHORTPATH );
- StringCchCopyW(pszPath, MAX_PATH, szGotPath);
- }
- }
- ppf->Release();
- }
- psl->Release();
- }
- return SUCCEEDED(hres);
- }
-
- void Shell_Free(void *p)
- {
- CoTaskMemFree(p);
- }
- }
|