Author: gadamopoulos Date: Wed Nov 6 09:48:29 2013 New Revision: 60873
URL: http://svn.reactos.org/svn/reactos?rev=60873&view=rev Log: [shell32] - Improve CDefaultContextMenu::InvokePidl so it can handle opening items that are not files
Modified: trunk/reactos/dll/win32/shell32/defcontextmenu.cpp
Modified: trunk/reactos/dll/win32/shell32/defcontextmenu.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/defcontex... ============================================================================== --- trunk/reactos/dll/win32/shell32/defcontextmenu.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/win32/shell32/defcontextmenu.cpp [iso-8859-1] Wed Nov 6 09:48:29 2013 @@ -1538,24 +1538,28 @@ HRESULT CDefaultContextMenu::InvokePidl(LPCMINVOKECOMMANDINFO lpcmi, LPCITEMIDLIST pidl, PStaticShellEntry pEntry) { - HRESULT hr; - STRRET strFile; - - hr = m_Dcm.psf->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &strFile); - if (hr != S_OK) - { - ERR("IShellFolder_GetDisplayNameOf failed for apidl\n"); - return hr; + LPITEMIDLIST pidlFull = ILCombine(m_Dcm.pidlFolder, pidl); + if (pidlFull == NULL) + { + return E_FAIL; }
WCHAR wszPath[MAX_PATH]; - hr = StrRetToBufW(&strFile, pidl, wszPath, MAX_PATH); - if (hr != S_OK) - return hr; - + BOOL bHasPath = SHGetPathFromIDListW(pidlFull, wszPath); + WCHAR wszDir[MAX_PATH]; - wcscpy(wszDir, wszPath); - PathRemoveFileSpec(wszDir); + if(bHasPath) + { + 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; ZeroMemory(&sei, sizeof(sei)); @@ -1563,9 +1567,20 @@ sei.hwnd = lpcmi->hwnd; sei.nShow = SW_SHOWNORMAL; sei.lpVerb = pEntry->szVerb; - sei.lpFile = wszPath; sei.lpDirectory = wszDir; + sei.lpIDList = pidlFull; + sei.hkeyClass = hkeyClass; + sei.fMask = SEE_MASK_CLASSKEY | SEE_MASK_IDLIST; + if (bHasPath) + { + sei.lpFile = wszPath; + } + ShellExecuteExW(&sei); + + RegCloseKey(hkeyClass); + + ILFree(pidlFull);
return S_OK; }