[shell32]

- Improve CDefaultContextMenu::InvokePidl so it can handle opening items that are not files

svn path=/trunk/; revision=60873
This commit is contained in:
Giannis Adamopoulos 2013-11-06 09:48:29 +00:00
parent 69844f7850
commit 2f9415777a

View file

@ -1538,24 +1538,28 @@ CDefaultContextMenu::TryToBrowse(
HRESULT HRESULT
CDefaultContextMenu::InvokePidl(LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl, PStaticShellEntry pEntry) CDefaultContextMenu::InvokePidl(LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl, PStaticShellEntry pEntry)
{ {
HRESULT hr; LPITEMIDLIST pidlFull = ILCombine(m_Dcm.pidlFolder, pidl);
STRRET strFile; if (pidlFull == NULL)
hr = m_Dcm.psf->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strFile);
if (hr != S_OK)
{ {
ERR("IShellFolder_GetDisplayNameOf failed for apidl\n"); return E_FAIL;
return hr;
} }
WCHAR wszPath[MAX_PATH]; WCHAR wszPath[MAX_PATH];
hr = StrRetToBufW(&strFile, pidl, wszPath, MAX_PATH); BOOL bHasPath = SHGetPathFromIDListW(pidlFull, wszPath);
if (hr != S_OK)
return hr;
WCHAR wszDir[MAX_PATH]; WCHAR wszDir[MAX_PATH];
wcscpy(wszDir, wszPath); if(bHasPath)
PathRemoveFileSpec(wszDir); {
wcscpy(wszDir, wszPath);
PathRemoveFileSpec(wszDir);
}
else
{
SHGetPathFromIDListW(m_Dcm.pidlFolder, wszDir);
}
HKEY hkeyClass;
RegOpenKeyExW(HKEY_CLASSES_ROOT, pEntry->szClass, 0, KEY_READ, &hkeyClass);
SHELLEXECUTEINFOW sei; SHELLEXECUTEINFOW sei;
ZeroMemory(&sei, sizeof(sei)); ZeroMemory(&sei, sizeof(sei));
@ -1563,10 +1567,21 @@ CDefaultContextMenu::InvokePidl(LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl,
sei.hwnd = lpcmi->hwnd; sei.hwnd = lpcmi->hwnd;
sei.nShow = SW_SHOWNORMAL; sei.nShow = SW_SHOWNORMAL;
sei.lpVerb = pEntry->szVerb; sei.lpVerb = pEntry->szVerb;
sei.lpFile = wszPath;
sei.lpDirectory = wszDir; sei.lpDirectory = wszDir;
sei.lpIDList = pidlFull;
sei.hkeyClass = hkeyClass;
sei.fMask = SEE_MASK_CLASSKEY | SEE_MASK_IDLIST;
if (bHasPath)
{
sei.lpFile = wszPath;
}
ShellExecuteExW(&sei); ShellExecuteExW(&sei);
RegCloseKey(hkeyClass);
ILFree(pidlFull);
return S_OK; return S_OK;
} }