Author: gadamopoulos
Date: Sun Nov 6 21:51:46 2016
New Revision: 73159
URL:
http://svn.reactos.org/svn/reactos?rev=73159&view=rev
Log:
[SHELL32]
- 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
Modified:
trunk/reactos/dll/win32/shell32/CShellLink.cpp
trunk/reactos/dll/win32/shell32/shlfolder.cpp
Modified: trunk/reactos/dll/win32/shell32/CShellLink.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/CShellLi…
==============================================================================
--- trunk/reactos/dll/win32/shell32/CShellLink.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/CShellLink.cpp [iso-8859-1] Sun Nov 6 21:51:46 2016
@@ -1975,6 +1975,13 @@
return FALSE;
}
+EXTERN_C HRESULT
+WINAPI
+SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder,
+ UINT cidl,
+ PCUITEMID_CHILD_ARRAY apidl,
+ DWORD dwFlags);
+
/**************************************************************************
* SH_ShellLinkDlgProc
*
@@ -2108,6 +2115,7 @@
switch(LOWORD(wParam))
{
case 14020:
+ SHOpenFolderAndSelectItems(pThis->pPidl, 0, NULL, 0);
///
/// FIXME
/// open target directory
Modified: trunk/reactos/dll/win32/shell32/shlfolder.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shlfolde…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shlfolder.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shlfolder.cpp [iso-8859-1] Sun Nov 6 21:51:46 2016
@@ -252,7 +252,7 @@
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 @@
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;
+}