diff --git a/dll/win32/browseui/shellfind/CFindFolder.cpp b/dll/win32/browseui/shellfind/CFindFolder.cpp index 0a2aec890a..779eb42f68 100644 --- a/dll/win32/browseui/shellfind/CFindFolder.cpp +++ b/dll/win32/browseui/shellfind/CFindFolder.cpp @@ -547,11 +547,19 @@ class CFindFolderContextMenu : for (UINT i = 0; i < cidl; i++) { - CComHeapPtr folderPidl(ILCreateFromPathW(_ILGetPath(apidl[i]))); + WCHAR path[MAX_PATH]; + wcscpy(path, (LPCWSTR) apidl[i]->mkid.abID); + CComHeapPtr folderPidl(ILCreateFromPathW(path)); if (!folderPidl) return E_OUTOFMEMORY; - LPCITEMIDLIST pidl = _ILGetFSPidl(apidl[i]); - SHOpenFolderAndSelectItems(folderPidl, 1, &pidl, 0); + CComHeapPtr pidl(ILCreateFromPathW((LPCWSTR) apidl[i]->mkid.abID)); + if (!pidl) + return E_OUTOFMEMORY; + + /* https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shopenfolderandselectitems */ + /* Says: If cidl is zero, then pidlFolder must point to a fully specified ITEMIDLIST */ + /* describing a single item to select. "cidl" is the second parameter listed below. */ + SHOpenFolderAndSelectItems(folderPidl, 0, &pidl, 0); } return S_OK; } diff --git a/dll/win32/shell32/shlfolder.cpp b/dll/win32/shell32/shlfolder.cpp index f652378616..a0d536ee71 100644 --- a/dll/win32/shell32/shlfolder.cpp +++ b/dll/win32/shell32/shlfolder.cpp @@ -392,8 +392,14 @@ SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder, DWORD dwFlags) { ERR("SHOpenFolderAndSelectItems() is hackplemented\n"); + TRACE("(pidlFolder=%p cidl=%d apidl= %p dwFlags=0x%08x)\n", pidlFolder, cidl, apidl, dwFlags); + PCIDLIST_ABSOLUTE pidlItem; - if (cidl) + + /* https://docs.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shopenfolderandselectitems */ + /* Says: If cidl is zero, then pidlFolder must point to a fully specified ITEMIDLIST */ + /* describing a single item to select. "cidl" is the incoming second parameter. */ + if (cidl) // cidl != 0 { /* Firefox sends a full pidl here dispite the fact it is a PCUITEMID_CHILD_ARRAY -_- */ if (ILGetNext(apidl[0]) != NULL) @@ -405,7 +411,7 @@ SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder, pidlItem = ILCombine(pidlFolder, apidl[0]); } } - else + else // cidl == 0 { pidlItem = pidlFolder; } @@ -427,8 +433,18 @@ SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder, return hr; WCHAR wszParams[MAX_PATH]; - wcscpy(wszParams, L"/select,"); - wcscat(wszParams, wszBuf); + + /* See cidl information in comments above. */ + + if (cidl) + { + wcscpy(wszParams, L"/select,"); + wcscat(wszParams, wszBuf); + } + else + { + wcscpy(wszParams, wszBuf); + } SHELLEXECUTEINFOW sei; memset(&sei, 0, sizeof sei);