[SHELL32]
authorGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 6 Nov 2016 21:51:46 +0000 (21:51 +0000)
committerGiannis Adamopoulos <gadamopoulos@reactos.org>
Sun, 6 Nov 2016 21:51:46 +0000 (21:51 +0000)
- Hackplement SHOpenFolderAndSelectItems by using the /select parameter of explorer.exe and selecting only the first of the requested items.
- Implement the "Find Target" button in the properties dialog of shortcuts to use SHOpenFolderAndSelectItems so as we can test it.
Based on the patch of Joachim Henze (reactosfanboy).
CORE-9367

svn path=/trunk/; revision=73159

reactos/dll/win32/shell32/CShellLink.cpp
reactos/dll/win32/shell32/shlfolder.cpp

index ffe4b89..b7afc0b 100644 (file)
@@ -1975,6 +1975,13 @@ INT_PTR CALLBACK ExtendedShortcutProc(HWND hwndDlg, UINT uMsg,
     return FALSE;
 }
 
+EXTERN_C HRESULT
+WINAPI
+SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder,
+                           UINT cidl,
+                           PCUITEMID_CHILD_ARRAY apidl,
+                           DWORD dwFlags);
+
 /**************************************************************************
  * SH_ShellLinkDlgProc
  *
@@ -2108,6 +2115,7 @@ INT_PTR CALLBACK CShellLink::SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM
             switch(LOWORD(wParam))
             {
                 case 14020:
+                    SHOpenFolderAndSelectItems(pThis->pPidl, 0, NULL, 0);
                     ///
                     /// FIXME
                     /// open target directory
index be18467..44ba710 100644 (file)
@@ -252,7 +252,7 @@ HRESULT SHELL32_BindToFS (LPCITEMIDLIST pidlRoot,
         ERR("Binding to file is unimplemented\n");
         return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
     }
-    if (!_ILIsFolder(pidlComplete) && !_ILIsDrive(pidlComplete))
+    if (!_ILIsFolder(pidlComplete))
     {
         ERR("Got an unknown type of pidl!\n");
         return E_FAIL;
@@ -525,6 +525,42 @@ SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder,
                            PCUITEMID_CHILD_ARRAY apidl,
                            DWORD dwFlags)
 {
-    FIXME("SHOpenFolderAndSelectItems() stub\n");
-    return E_NOTIMPL;
+    ERR("SHOpenFolderAndSelectItems() is hackplemented\n");
+    PCIDLIST_ABSOLUTE pidlItem;
+    if (cidl)
+        pidlItem = ILCombine(pidlFolder, apidl[0]);
+    else
+        pidlItem = pidlFolder;
+
+    CComPtr<IShellFolder> psfDesktop;
+
+    HRESULT hr = SHGetDesktopFolder(&psfDesktop);
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
+
+    STRRET strret;
+    hr = psfDesktop->GetDisplayNameOf(pidlItem, SHGDN_FORPARSING, &strret);
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
+
+    WCHAR wszBuf[MAX_PATH];
+    hr = StrRetToBufW(&strret, pidlItem, wszBuf, _countof(wszBuf));
+    if (FAILED_UNEXPECTEDLY(hr))
+        return hr;
+
+    WCHAR wszParams[MAX_PATH];
+    wcscpy(wszParams, L"/select,");
+    wcscat(wszParams, wszBuf);
+
+    SHELLEXECUTEINFOW sei;
+    memset(&sei, 0, sizeof sei);
+    sei.cbSize = sizeof sei;
+    sei.fMask = SEE_MASK_WAITFORINPUTIDLE;
+    sei.lpFile = L"explorer.exe";
+    sei.lpParameters = wszParams;
+
+    if (ShellExecuteExW(&sei))
+        return S_OK;
+    else
+        return E_FAIL;
 }