Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Software *ResolveIt(LPTSTR lpszLinkFile) {
- HWND hwnd = nullptr;
- HRESULT hres;
- IShellLink *psl;
- WCHAR appPath[MAX_PATH];
- WCHAR szDescription[MAX_PATH];
- WIN32_FIND_DATA wfd;
- WCHAR pszIconPath[MAX_PATH];
- int idx{};
- Software *sft = nullptr;
- // Get a pointer to the IShellLink interface. It is assumed that
- // CoInitialize has already been called.
- hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
- IID_IShellLink, (LPVOID *)&psl);
- if (SUCCEEDED(hres)) {
- IPersistFile *ppf;
- hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf);
- if (SUCCEEDED(hres)) {
- hres = ppf->Load(lpszLinkFile, STGM_READ);
- if (SUCCEEDED(hres)) {
- hres = psl->Resolve(hwnd, SLR_NO_UI);
- if (SUCCEEDED(hres)) {
- // qDebug() << QString::fromWCharArray(lpszLinkFile);
- hres =
- psl->GetPath(appPath, MAX_PATH, (WIN32_FIND_DATA *)&wfd,
- SLGP_SHORTPATH);
- if (nullptr == wcsstr(appPath, L".exe"))
- hres = -1;
- if (SUCCEEDED(hres)) {
- psl->GetDescription(szDescription, MAX_PATH);
- }
- if (SUCCEEDED(hres)) {
- psl->GetIconLocation(pszIconPath, MAX_PATH, &idx);
- }
- // sft = new Software(szDescription, appPath, pszIconPath,
- // idx);
- sft = new Software(lpszLinkFile, appPath, appPath, idx);
- // if (0 == wcslen(pszIconPath))
- // sft->Icon = appPath;
- }
- }
- ppf->Release();
- }
- psl->Release();
- }
- return sft;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement