mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-27 15:44:12 +08:00
56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
|
#include <Shobjidl.h>
|
||
|
#include <Windows.h>
|
||
|
#include <Shobjidl.h>
|
||
|
#include <iostream>
|
||
|
#include <initguid.h>
|
||
|
#include <ShlGuid.h>
|
||
|
#include <strsafe.h>
|
||
|
#include"define.h"
|
||
|
void GetLnkTargetPath(wchar_t* lnkFilePath,wchar_t *path,wchar_t*tgtpath,wchar_t*iconpath,wchar_t*dirpath) {
|
||
|
wcscpy(path,L"");wcscpy(tgtpath,L"");wcscpy(iconpath,L"");
|
||
|
CoInitialize(NULL);
|
||
|
|
||
|
IShellLink* shellLink;
|
||
|
HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&shellLink);
|
||
|
|
||
|
if (SUCCEEDED(hr)) {
|
||
|
IPersistFile* persistFile;
|
||
|
hr = shellLink->QueryInterface(IID_IPersistFile, (LPVOID*)&persistFile);
|
||
|
|
||
|
if (SUCCEEDED(hr)) {
|
||
|
WCHAR wsz[MAX_PATH];
|
||
|
StringCchCopy(wsz, MAX_PATH, lnkFilePath);
|
||
|
|
||
|
hr = persistFile->Load(wsz, STGM_READ);
|
||
|
|
||
|
if (SUCCEEDED(hr)) {
|
||
|
hr = shellLink->Resolve(NULL, SLR_NO_UI);
|
||
|
|
||
|
if (SUCCEEDED(hr)) {
|
||
|
WIN32_FIND_DATA findData;
|
||
|
int x;
|
||
|
hr=shellLink->GetIconLocation(iconpath, MAX_PATH, &x);
|
||
|
if(FAILED(hr))
|
||
|
wcscpy(iconpath,L"");
|
||
|
hr=shellLink->GetArguments(tgtpath, MAX_PATH);
|
||
|
if(FAILED(hr))
|
||
|
wcscpy(tgtpath,L"");
|
||
|
hr = shellLink->GetPath(path, MAX_PATH, &findData, SLGP_RAWPATH);
|
||
|
|
||
|
if (FAILED(hr))
|
||
|
wcscpy(path,L"");
|
||
|
hr=shellLink->GetWorkingDirectory(dirpath,MAX_PATH);
|
||
|
if (FAILED(hr))
|
||
|
wcscpy(path,L"");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
persistFile->Release();
|
||
|
}
|
||
|
|
||
|
shellLink->Release();
|
||
|
}
|
||
|
|
||
|
CoUninitialize();
|
||
|
|
||
|
}
|