1.10.5
This commit is contained in:
parent
be8bc16c14
commit
27ceada829
|
@ -10,9 +10,56 @@
|
||||||
#include <Shlwapi.h>
|
#include <Shlwapi.h>
|
||||||
#include <Shlobj.h>
|
#include <Shlobj.h>
|
||||||
|
|
||||||
|
QString ResolveShortcutUrl(const QString& LinkPath)
|
||||||
|
{
|
||||||
|
QUrl Url;
|
||||||
|
|
||||||
|
IShellLink* pShellLink = nullptr;
|
||||||
|
HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, reinterpret_cast<void**>(&pShellLink));
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
IPersistFile* pPersistFile = nullptr;
|
||||||
|
hr = pShellLink->QueryInterface(IID_IPersistFile, reinterpret_cast<void**>(&pPersistFile));
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
hr = pPersistFile->Load(LinkPath.toStdWString().c_str(), STGM_READ);
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
PIDLIST_ABSOLUTE pidl;
|
||||||
|
hr = pShellLink->GetIDList(&pidl);
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
LPWSTR url = nullptr;
|
||||||
|
SHGetNameFromIDList(pidl, SIGDN_URL, &url);
|
||||||
|
|
||||||
|
if (url) {
|
||||||
|
Url = QString::fromWCharArray(url);
|
||||||
|
|
||||||
|
CoTaskMemFree(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
CoTaskMemFree(pidl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pPersistFile->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
pShellLink->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Url.isLocalFile())
|
||||||
|
return Url.path().mid(1).replace("/", "\\");
|
||||||
|
return Url.toString();;
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap ResolveShortcut(const QString& LinkPath)
|
QVariantMap ResolveShortcut(const QString& LinkPath)
|
||||||
{
|
{
|
||||||
QVariantMap Link;
|
QVariantMap Link;
|
||||||
|
|
||||||
HRESULT hRes = E_FAIL;
|
HRESULT hRes = E_FAIL;
|
||||||
IShellLink* psl = NULL;
|
IShellLink* psl = NULL;
|
||||||
|
@ -41,14 +88,14 @@ QVariantMap ResolveShortcut(const QString& LinkPath)
|
||||||
{
|
{
|
||||||
// Get the path to the shortcut target
|
// Get the path to the shortcut target
|
||||||
hRes = psl->GetPath(szPath, ARRAYSIZE(szPath), &wfd, SLGP_RAWPATH);
|
hRes = psl->GetPath(szPath, ARRAYSIZE(szPath), &wfd, SLGP_RAWPATH);
|
||||||
if (FAILED(hRes))
|
if (hRes == S_OK)
|
||||||
return Link;
|
Link["Path"] = QString::fromWCharArray(szPath);
|
||||||
Link["Path"] = QString::fromWCharArray(szPath);
|
else
|
||||||
|
Link["Path"] = ResolveShortcutUrl(LinkPath);
|
||||||
|
|
||||||
hRes = psl->GetArguments(szPath, ARRAYSIZE(szPath));
|
hRes = psl->GetArguments(szPath, ARRAYSIZE(szPath));
|
||||||
if (FAILED(hRes))
|
if (!FAILED(hRes))
|
||||||
return Link;
|
Link["Arguments"] = QString::fromWCharArray(szPath);
|
||||||
Link["Arguments"] = QString::fromWCharArray(szPath);
|
|
||||||
|
|
||||||
hRes = psl->GetWorkingDirectory(szPath, ARRAYSIZE(szPath));
|
hRes = psl->GetWorkingDirectory(szPath, ARRAYSIZE(szPath));
|
||||||
if (!FAILED(hRes))
|
if (!FAILED(hRes))
|
||||||
|
|
|
@ -507,6 +507,8 @@ void CSandBoxPlus::ScanStartMenu()
|
||||||
bChanged = true;
|
bChanged = true;
|
||||||
|
|
||||||
pLink->Target = Link["Path"].toString();
|
pLink->Target = Link["Path"].toString();
|
||||||
|
if(pLink->Target.mid(1,2) != ":\\")
|
||||||
|
pLink->Url = true;
|
||||||
pLink->Arguments = Link["Arguments"].toString();
|
pLink->Arguments = Link["Arguments"].toString();
|
||||||
pLink->Icon = Link["IconPath"].toString();
|
pLink->Icon = Link["IconPath"].toString();
|
||||||
pLink->IconIndex = Link["IconIndex"].toInt();
|
pLink->IconIndex = Link["IconIndex"].toInt();
|
||||||
|
|
Loading…
Reference in New Issue