2011-05-15 15:55:49 +00:00
|
|
|
/*
|
2011-09-08 22:43:43 +00:00
|
|
|
* Shell Folder stuff
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
2011-09-08 22:43:43 +00:00
|
|
|
* Copyright 1997 Marcus Meissner
|
|
|
|
* Copyright 1998, 1999, 2002 Juergen Schmied
|
2018-07-08 15:01:12 +00:00
|
|
|
* Copyright 2018 Katayama Hirofumi MZ
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
2011-09-08 22:43:43 +00:00
|
|
|
* IShellFolder2 and related interfaces
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "precomp.h"
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-06 23:52:38 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* GetNextElement (internal function)
|
|
|
|
*
|
|
|
|
* Gets a part of a string till the first backslash.
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* pszNext [IN] string to get the element from
|
|
|
|
* pszOut [IN] pointer to buffer which receives string
|
|
|
|
* dwOut [IN] length of pszOut
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* LPSTR pointer to first, not yet parsed char
|
|
|
|
*/
|
|
|
|
|
|
|
|
LPCWSTR GetNextElementW (LPCWSTR pszNext, LPWSTR pszOut, DWORD dwOut)
|
|
|
|
{
|
|
|
|
LPCWSTR pszTail = pszNext;
|
|
|
|
DWORD dwCopy;
|
|
|
|
|
|
|
|
TRACE ("(%s %p 0x%08x)\n", debugstr_w (pszNext), pszOut, dwOut);
|
|
|
|
|
|
|
|
*pszOut = 0x0000;
|
|
|
|
|
|
|
|
if (!pszNext || !*pszNext)
|
2011-09-08 22:43:43 +00:00
|
|
|
return NULL;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
while (*pszTail && (*pszTail != (WCHAR) '\\'))
|
2011-09-08 22:43:43 +00:00
|
|
|
pszTail++;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
dwCopy = pszTail - pszNext + 1;
|
|
|
|
lstrcpynW (pszOut, pszNext, (dwOut < dwCopy) ? dwOut : dwCopy);
|
|
|
|
|
|
|
|
if (*pszTail)
|
2011-09-08 22:43:43 +00:00
|
|
|
pszTail++;
|
2011-05-15 15:55:49 +00:00
|
|
|
else
|
2011-09-08 22:43:43 +00:00
|
|
|
pszTail = NULL;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
TRACE ("--(%s %s 0x%08x %p)\n", debugstr_w (pszNext), debugstr_w (pszOut), dwOut, pszTail);
|
|
|
|
return pszTail;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc,
|
2011-09-08 22:43:43 +00:00
|
|
|
LPITEMIDLIST * pidlInOut, LPOLESTR szNext, DWORD * pEaten, DWORD * pdwAttributes)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
HRESULT hr = E_INVALIDARG;
|
2014-06-07 13:54:11 +00:00
|
|
|
LPITEMIDLIST pidlIn = pidlInOut ? *pidlInOut : NULL;
|
|
|
|
LPITEMIDLIST pidlOut = NULL;
|
|
|
|
LPITEMIDLIST pidlTemp = NULL;
|
|
|
|
CComPtr<IShellFolder> psfChild;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2014-06-07 13:54:11 +00:00
|
|
|
TRACE ("(%p, %p, %p, %s)\n", psf, pbc, pidlIn, debugstr_w (szNext));
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
/* get the shellfolder for the child pidl and let it analyse further */
|
2014-06-07 13:54:11 +00:00
|
|
|
hr = psf->BindToObject(pidlIn, pbc, IID_PPV_ARG(IShellFolder, &psfChild));
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-08 22:43:43 +00:00
|
|
|
hr = psfChild->ParseDisplayName(hwndOwner, pbc, szNext, pEaten, &pidlOut, pdwAttributes);
|
2014-06-07 13:54:11 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2014-06-07 13:54:11 +00:00
|
|
|
pidlTemp = ILCombine (pidlIn, pidlOut);
|
|
|
|
if (!pidlTemp)
|
|
|
|
{
|
2011-09-08 22:43:43 +00:00
|
|
|
hr = E_OUTOFMEMORY;
|
2014-06-07 13:54:11 +00:00
|
|
|
if (pidlOut)
|
|
|
|
ILFree(pidlOut);
|
|
|
|
return hr;
|
2011-09-08 22:43:43 +00:00
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-08 22:43:43 +00:00
|
|
|
if (pidlOut)
|
|
|
|
ILFree (pidlOut);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2014-06-07 13:54:11 +00:00
|
|
|
if (pidlIn)
|
|
|
|
ILFree (pidlIn);
|
|
|
|
|
2011-05-15 15:55:49 +00:00
|
|
|
*pidlInOut = pidlTemp;
|
|
|
|
|
|
|
|
TRACE ("-- pidl=%p ret=0x%08x\n", pidlInOut ? *pidlInOut : NULL, hr);
|
2014-06-07 13:54:11 +00:00
|
|
|
return S_OK;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2011-09-08 22:43:43 +00:00
|
|
|
* SHELL32_CoCreateInitSF
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* Creates a shell folder and initializes it with a pidl and a root folder
|
|
|
|
* via IPersistFolder3 or IPersistFolder.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* pathRoot can be NULL for Folders being a drive.
|
|
|
|
* In this case the absolute path is built from pidlChild (eg. C:)
|
|
|
|
*/
|
2017-07-07 20:34:27 +00:00
|
|
|
HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO* ppfti,
|
|
|
|
LPCITEMIDLIST pidlChild, const GUID* clsid, REFIID riid, LPVOID *ppvOut)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2014-08-20 12:25:09 +00:00
|
|
|
CComPtr<IShellFolder> pShellFolder;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2016-08-09 18:05:50 +00:00
|
|
|
hr = SHCoCreateInstance(NULL, clsid, NULL, IID_PPV_ARG(IShellFolder, &pShellFolder));
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2016-08-09 18:05:50 +00:00
|
|
|
LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild);
|
|
|
|
CComPtr<IPersistFolder> ppf;
|
|
|
|
CComPtr<IPersistFolder3> ppf3;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2017-07-07 20:34:27 +00:00
|
|
|
if (ppfti && SUCCEEDED(pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder3, &ppf3))))
|
2016-08-09 18:05:50 +00:00
|
|
|
{
|
2017-07-07 20:34:27 +00:00
|
|
|
ppf3->InitializeEx(NULL, pidlAbsolute, ppfti);
|
2016-08-09 18:05:50 +00:00
|
|
|
}
|
|
|
|
else if (SUCCEEDED(pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder, &ppf))))
|
|
|
|
{
|
|
|
|
ppf->Initialize(pidlAbsolute);
|
|
|
|
}
|
|
|
|
ILFree (pidlAbsolute);
|
|
|
|
|
|
|
|
return pShellFolder->QueryInterface(riid, ppvOut);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
2017-07-07 20:34:27 +00:00
|
|
|
HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, const GUID* clsid,
|
|
|
|
int csidl, REFIID riid, LPVOID *ppvOut)
|
2015-08-31 23:44:02 +00:00
|
|
|
{
|
2017-07-07 20:34:27 +00:00
|
|
|
/* fill the PERSIST_FOLDER_TARGET_INFO */
|
|
|
|
PERSIST_FOLDER_TARGET_INFO pfti = {0};
|
|
|
|
pfti.dwAttributes = -1;
|
|
|
|
pfti.csidl = csidl;
|
2015-08-31 23:44:02 +00:00
|
|
|
|
2017-07-07 20:34:27 +00:00
|
|
|
return SHELL32_CoCreateInitSF(pidlRoot, &pfti, NULL, clsid, riid, ppvOut);
|
2015-08-31 23:44:02 +00:00
|
|
|
}
|
|
|
|
|
2017-07-07 20:34:27 +00:00
|
|
|
HRESULT SHELL32_BindToSF (LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO* ppfti,
|
|
|
|
LPCITEMIDLIST pidl, const GUID* clsid, REFIID riid, LPVOID *ppvOut)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2017-07-07 20:34:27 +00:00
|
|
|
PITEMID_CHILD pidlChild = ILCloneFirst (pidl);
|
|
|
|
if (!pidlChild)
|
2015-08-31 23:44:02 +00:00
|
|
|
return E_FAIL;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2017-07-07 20:34:27 +00:00
|
|
|
CComPtr<IShellFolder> psf;
|
|
|
|
HRESULT hr = SHELL32_CoCreateInitSF(pidlRoot,
|
|
|
|
ppfti,
|
|
|
|
pidlChild,
|
|
|
|
clsid,
|
|
|
|
IID_PPV_ARG(IShellFolder, &psf));
|
|
|
|
ILFree(pidlChild);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2017-07-07 20:34:27 +00:00
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return hr;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2017-07-07 20:34:27 +00:00
|
|
|
if (_ILIsPidlSimple (pidl))
|
|
|
|
return psf->QueryInterface(riid, ppvOut);
|
|
|
|
else
|
|
|
|
return psf->BindToObject(ILGetNext (pidl), NULL, riid, ppvOut);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2011-09-08 22:43:43 +00:00
|
|
|
* SHELL32_GetDisplayNameOfChild
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* Retrieves the display name of a child object of a shellfolder.
|
|
|
|
*
|
|
|
|
* For a pidl eg. [subpidl1][subpidl2][subpidl3]:
|
|
|
|
* - it binds to the child shellfolder [subpidl1]
|
|
|
|
* - asks it for the displayname of [subpidl2][subpidl3]
|
|
|
|
*
|
|
|
|
* Is possible the pidl is a simple pidl. In this case it asks the
|
|
|
|
* subfolder for the displayname of an empty pidl. The subfolder
|
|
|
|
* returns the own displayname eg. "::{guid}". This is used for
|
|
|
|
* virtual folders with the registry key WantsFORPARSING set.
|
|
|
|
*/
|
|
|
|
HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf,
|
2015-08-31 11:28:24 +00:00
|
|
|
LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2015-08-31 11:28:24 +00:00
|
|
|
LPITEMIDLIST pidlFirst = ILCloneFirst(pidl);
|
|
|
|
if (!pidlFirst)
|
|
|
|
return E_OUTOFMEMORY;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2015-08-31 11:28:24 +00:00
|
|
|
CComPtr<IShellFolder> psfChild;
|
|
|
|
HRESULT hr = psf->BindToObject(pidlFirst, NULL, IID_PPV_ARG(IShellFolder, &psfChild));
|
|
|
|
if (SUCCEEDED (hr))
|
2011-12-17 22:48:16 +00:00
|
|
|
{
|
2015-08-31 11:28:24 +00:00
|
|
|
hr = psfChild->GetDisplayNameOf(ILGetNext (pidl), dwFlags, strRet);
|
|
|
|
}
|
|
|
|
ILFree (pidlFirst);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2016-11-04 23:11:29 +00:00
|
|
|
HRESULT SHELL32_CompareChildren(IShellFolder2* psf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
|
|
|
|
{
|
|
|
|
PUIDLIST_RELATIVE nextpidl1 = ILGetNext (pidl1);
|
|
|
|
PUIDLIST_RELATIVE nextpidl2 = ILGetNext (pidl2);
|
|
|
|
|
|
|
|
bool isEmpty1 = _ILIsDesktop(nextpidl1);
|
|
|
|
bool isEmpty2 = _ILIsDesktop(nextpidl2);
|
|
|
|
if (isEmpty1 || isEmpty2)
|
|
|
|
return MAKE_COMPARE_HRESULT(isEmpty2 - isEmpty1);
|
|
|
|
|
|
|
|
PITEMID_CHILD firstpidl = ILCloneFirst (pidl1);
|
|
|
|
if (!firstpidl)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
CComPtr<IShellFolder> psf2;
|
|
|
|
HRESULT hr = psf->BindToObject(firstpidl, 0, IID_PPV_ARG(IShellFolder, &psf2));
|
|
|
|
ILFree(firstpidl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return MAKE_COMPARE_HRESULT(0);
|
|
|
|
|
|
|
|
return psf2->CompareIDs(lParam, nextpidl1, nextpidl2);
|
|
|
|
}
|
|
|
|
|
2015-10-26 15:07:44 +00:00
|
|
|
HRESULT SHELL32_CompareDetails(IShellFolder2* isf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
|
|
|
|
{
|
|
|
|
SHELLDETAILS sd;
|
|
|
|
WCHAR wszItem1[MAX_PATH], wszItem2[MAX_PATH];
|
2016-09-22 16:22:44 +00:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = isf->GetDetailsOf(pidl1, lParam, &sd);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return MAKE_COMPARE_HRESULT(1);
|
|
|
|
|
|
|
|
hres = StrRetToBufW(&sd.str, pidl1, wszItem1, MAX_PATH);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return MAKE_COMPARE_HRESULT(1);
|
|
|
|
|
|
|
|
hres = isf->GetDetailsOf(pidl2, lParam, &sd);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return MAKE_COMPARE_HRESULT(1);
|
|
|
|
|
|
|
|
hres = StrRetToBufW(&sd.str, pidl2, wszItem2, MAX_PATH);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return MAKE_COMPARE_HRESULT(1);
|
2015-10-26 15:07:44 +00:00
|
|
|
|
|
|
|
int ret = wcsicmp(wszItem1, wszItem2);
|
2016-11-04 23:11:29 +00:00
|
|
|
if (ret == 0)
|
|
|
|
return SHELL32_CompareChildren(isf, lParam, pidl1, pidl2);
|
2015-10-26 15:07:44 +00:00
|
|
|
|
|
|
|
return MAKE_COMPARE_HRESULT(ret);
|
|
|
|
}
|
|
|
|
|
2016-10-02 13:22:01 +00:00
|
|
|
void AddClassKeyToArray(const WCHAR * szClass, HKEY* array, UINT* cKeys)
|
|
|
|
{
|
|
|
|
if (*cKeys >= 16)
|
|
|
|
return;
|
|
|
|
|
|
|
|
HKEY hkey;
|
|
|
|
LSTATUS result = RegOpenKeyExW(HKEY_CLASSES_ROOT, szClass, 0, KEY_READ | KEY_QUERY_VALUE, &hkey);
|
|
|
|
if (result != ERROR_SUCCESS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
array[*cKeys] = hkey;
|
|
|
|
*cKeys += 1;
|
|
|
|
}
|
|
|
|
|
2016-11-15 20:14:56 +00:00
|
|
|
void AddFSClassKeysToArray(PCUITEMID_CHILD pidl, HKEY* array, UINT* cKeys)
|
|
|
|
{
|
|
|
|
if (_ILIsValue(pidl))
|
|
|
|
{
|
|
|
|
FileStructW* pFileData = _ILGetFileStructW(pidl);
|
|
|
|
LPWSTR extension = PathFindExtension(pFileData->wszName);
|
|
|
|
|
|
|
|
if (extension)
|
|
|
|
{
|
|
|
|
AddClassKeyToArray(extension, array, cKeys);
|
|
|
|
|
2017-08-17 16:35:16 +00:00
|
|
|
WCHAR wszClass[MAX_PATH], wszClass2[MAX_PATH];
|
2016-11-15 20:14:56 +00:00
|
|
|
DWORD dwSize = sizeof(wszClass);
|
|
|
|
if (RegGetValueW(HKEY_CLASSES_ROOT, extension, NULL, RRF_RT_REG_SZ, NULL, wszClass, &dwSize) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
swprintf(wszClass2, L"%s//%s", extension, wszClass);
|
|
|
|
|
|
|
|
AddClassKeyToArray(wszClass, array, cKeys);
|
|
|
|
AddClassKeyToArray(wszClass2, array, cKeys);
|
|
|
|
}
|
|
|
|
|
|
|
|
swprintf(wszClass2, L"SystemFileAssociations//%s", extension);
|
|
|
|
AddClassKeyToArray(wszClass2, array, cKeys);
|
|
|
|
|
|
|
|
if (RegGetValueW(HKEY_CLASSES_ROOT, extension, L"PerceivedType ", RRF_RT_REG_SZ, NULL, wszClass, &dwSize) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
swprintf(wszClass2, L"SystemFileAssociations//%s", wszClass);
|
|
|
|
AddClassKeyToArray(wszClass2, array, cKeys);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AddClassKeyToArray(L"AllFilesystemObjects", array, cKeys);
|
|
|
|
AddClassKeyToArray(L"*", array, cKeys);
|
|
|
|
}
|
|
|
|
else if (_ILIsFolder(pidl))
|
|
|
|
{
|
|
|
|
AddClassKeyToArray(L"AllFilesystemObjects", array, cKeys);
|
|
|
|
AddClassKeyToArray(L"Directory", array, cKeys);
|
|
|
|
AddClassKeyToArray(L"Folder", array, cKeys);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Got non FS pidl\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-17 14:35:19 +00:00
|
|
|
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE* ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
|
|
|
|
{
|
|
|
|
UINT cfShellIDList = RegisterClipboardFormatW(CFSTR_SHELLIDLIST);
|
|
|
|
if (!cfShellIDList)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
FORMATETC fmt;
|
|
|
|
InitFormatEtc (fmt, cfShellIDList, TYMED_HGLOBAL);
|
|
|
|
|
|
|
|
HRESULT hr = pDataObject->QueryGetData(&fmt);
|
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
STGMEDIUM medium;
|
|
|
|
hr = pDataObject->GetData(&fmt, &medium);
|
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* lock the handle */
|
|
|
|
LPIDA lpcida = (LPIDA)GlobalLock(medium.hGlobal);
|
|
|
|
if (!lpcida)
|
|
|
|
{
|
|
|
|
ReleaseStgMedium(&medium);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert the data into pidl */
|
|
|
|
LPITEMIDLIST pidl;
|
|
|
|
LPITEMIDLIST *apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
|
|
|
|
if (!apidl)
|
|
|
|
{
|
|
|
|
ReleaseStgMedium(&medium);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ppidlfolder = pidl;
|
|
|
|
*apidlItems = apidl;
|
|
|
|
*pcidl = lpcida->cidl;
|
|
|
|
|
|
|
|
ReleaseStgMedium(&medium);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-05-15 15:55:49 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* SHCreateLinks
|
|
|
|
*
|
|
|
|
* Undocumented.
|
|
|
|
*/
|
2014-08-20 00:39:40 +00:00
|
|
|
HRESULT WINAPI SHCreateLinks( HWND hWnd, LPCSTR lpszDir, IDataObject * lpDataObject,
|
2011-05-15 15:55:49 +00:00
|
|
|
UINT uFlags, LPITEMIDLIST *lppidlLinks)
|
|
|
|
{
|
2014-08-20 00:39:40 +00:00
|
|
|
FIXME("%p %s %p %08x %p\n", hWnd, lpszDir, lpDataObject, uFlags, lppidlLinks);
|
2011-05-15 15:55:49 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SHOpenFolderAndSelectItems
|
|
|
|
*
|
|
|
|
* Unimplemented.
|
|
|
|
*/
|
|
|
|
EXTERN_C HRESULT
|
|
|
|
WINAPI
|
|
|
|
SHOpenFolderAndSelectItems(LPITEMIDLIST pidlFolder,
|
|
|
|
UINT cidl,
|
|
|
|
PCUITEMID_CHILD_ARRAY apidl,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
2016-11-06 21:51:46 +00:00
|
|
|
ERR("SHOpenFolderAndSelectItems() is hackplemented\n");
|
|
|
|
PCIDLIST_ABSOLUTE pidlItem;
|
|
|
|
if (cidl)
|
2016-11-06 22:25:02 +00:00
|
|
|
{
|
|
|
|
/* Firefox sends a full pidl here dispite the fact it is a PCUITEMID_CHILD_ARRAY -_- */
|
|
|
|
if (ILGetNext(apidl[0]) != NULL)
|
|
|
|
{
|
|
|
|
pidlItem = apidl[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pidlItem = ILCombine(pidlFolder, apidl[0]);
|
|
|
|
}
|
|
|
|
}
|
2016-11-06 21:51:46 +00:00
|
|
|
else
|
2016-11-06 22:25:02 +00:00
|
|
|
{
|
2016-11-06 21:51:46 +00:00
|
|
|
pidlItem = pidlFolder;
|
2016-11-06 22:25:02 +00:00
|
|
|
}
|
2016-11-06 21:51:46 +00:00
|
|
|
|
|
|
|
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;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
2018-07-08 15:01:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* for internal use
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI
|
|
|
|
Shell_DefaultContextMenuCallBack(IShellFolder *psf, IDataObject *pdtobj)
|
|
|
|
{
|
|
|
|
PIDLIST_ABSOLUTE pidlFolder;
|
|
|
|
PUITEMID_CHILD *apidl;
|
|
|
|
UINT cidl;
|
|
|
|
HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
|
|
|
|
if (FAILED_UNEXPECTEDLY(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (cidl > 1)
|
|
|
|
{
|
|
|
|
ERR("SHMultiFileProperties is not yet implemented\n");
|
|
|
|
SHFree(pidlFolder);
|
|
|
|
_ILFreeaPidl(apidl, cidl);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
STRRET strFile;
|
|
|
|
hr = psf->GetDisplayNameOf(apidl[0], SHGDN_FORPARSING, &strFile);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = SH_ShowPropertiesDialog(strFile.pOleStr, pidlFolder, apidl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
ERR("SH_ShowPropertiesDialog failed\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Failed to get display name\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
SHFree(pidlFolder);
|
|
|
|
_ILFreeaPidl(apidl, cidl);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|