ReactOS  0.4.13-dev-52-g0efcfec
shlfolder.cpp File Reference
#include "precomp.h"
Include dependency graph for shlfolder.cpp:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
LPCWSTR GetNextElementW (LPCWSTR pszNext, LPWSTR pszOut, DWORD dwOut)
 
HRESULT SHELL32_ParseNextElement (IShellFolder2 *psf, HWND hwndOwner, LPBC pbc, LPITEMIDLIST *pidlInOut, LPOLESTR szNext, DWORD *pEaten, DWORD *pdwAttributes)
 
HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO *ppfti, LPCITEMIDLIST pidlChild, const GUID *clsid, REFIID riid, LPVOID *ppvOut)
 
HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, const GUID *clsid, int csidl, REFIID riid, LPVOID *ppvOut)
 
HRESULT SHELL32_BindToSF (LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO *ppfti, LPCITEMIDLIST pidl, const GUID *clsid, REFIID riid, LPVOID *ppvOut)
 
HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 *psf, LPCITEMIDLIST pidl, DWORD dwFlags, LPSTRRET strRet)
 
HRESULT SHELL32_CompareChildren (IShellFolder2 *psf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
 
HRESULT SHELL32_CompareDetails (IShellFolder2 *isf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
 
void AddClassKeyToArray (const WCHAR *szClass, HKEY *array, UINT *cKeys)
 
void AddFSClassKeysToArray (PCUITEMID_CHILD pidl, HKEY *array, UINT *cKeys)
 
HRESULT SH_GetApidlFromDataObject (IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
 
HRESULT WINAPI SHCreateLinks (HWND hWnd, LPCSTR lpszDir, IDataObject *lpDataObject, UINT uFlags, LPITEMIDLIST *lppidlLinks)
 
EXTERN_C HRESULT WINAPI SHOpenFolderAndSelectItems (LPITEMIDLIST pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD dwFlags)
 
HRESULT WINAPI Shell_DefaultContextMenuCallBack (IShellFolder *psf, IDataObject *pdtobj)
 

Function Documentation

◆ AddClassKeyToArray()

void AddClassKeyToArray ( const WCHAR szClass,
HKEY array,
UINT cKeys 
)

Definition at line 267 of file shlfolder.cpp.

268 {
269  if (*cKeys >= 16)
270  return;
271 
272  HKEY hkey;
274  if (result != ERROR_SUCCESS)
275  return;
276 
277  array[*cKeys] = hkey;
278  *cKeys += 1;
279 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
GLuint64EXT * result
Definition: glext.h:11304

Referenced by AddFSClassKeysToArray(), CDrivesContextMenu_CreateInstance(), CGuidItemContextMenu_CreateInstance(), CDrivesFolder::CreateViewObject(), CDesktopFolder::CreateViewObject(), CFSFolder::CreateViewObject(), and CNetFolder::GetUIObjectOf().

◆ AddFSClassKeysToArray()

void AddFSClassKeysToArray ( PCUITEMID_CHILD  pidl,
HKEY array,
UINT cKeys 
)

Definition at line 281 of file shlfolder.cpp.

282 {
283  if (_ILIsValue(pidl))
284  {
285  FileStructW* pFileData = _ILGetFileStructW(pidl);
286  LPWSTR extension = PathFindExtension(pFileData->wszName);
287 
288  if (extension)
289  {
290  AddClassKeyToArray(extension, array, cKeys);
291 
292  WCHAR wszClass[MAX_PATH], wszClass2[MAX_PATH];
293  DWORD dwSize = sizeof(wszClass);
294  if (RegGetValueW(HKEY_CLASSES_ROOT, extension, NULL, RRF_RT_REG_SZ, NULL, wszClass, &dwSize) == ERROR_SUCCESS)
295  {
296  swprintf(wszClass2, L"%s//%s", extension, wszClass);
297 
298  AddClassKeyToArray(wszClass, array, cKeys);
299  AddClassKeyToArray(wszClass2, array, cKeys);
300  }
301 
302  swprintf(wszClass2, L"SystemFileAssociations//%s", extension);
303  AddClassKeyToArray(wszClass2, array, cKeys);
304 
305  if (RegGetValueW(HKEY_CLASSES_ROOT, extension, L"PerceivedType ", RRF_RT_REG_SZ, NULL, wszClass, &dwSize) == ERROR_SUCCESS)
306  {
307  swprintf(wszClass2, L"SystemFileAssociations//%s", wszClass);
308  AddClassKeyToArray(wszClass2, array, cKeys);
309  }
310  }
311 
312  AddClassKeyToArray(L"AllFilesystemObjects", array, cKeys);
313  AddClassKeyToArray(L"*", array, cKeys);
314  }
315  else if (_ILIsFolder(pidl))
316  {
317  AddClassKeyToArray(L"AllFilesystemObjects", array, cKeys);
318  AddClassKeyToArray(L"Directory", array, cKeys);
319  AddClassKeyToArray(L"Folder", array, cKeys);
320  }
321  else
322  {
323  ERR("Got non FS pidl\n");
324  }
325 }
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1975
#define ERROR_SUCCESS
Definition: deptool.c:10
WCHAR wszName[1]
Definition: shlfolder.c:1555
void AddClassKeyToArray(const WCHAR *szClass, HKEY *array, UINT *cKeys)
Definition: shlfolder.cpp:267
#define RRF_RT_REG_SZ
Definition: driver.c:575
BOOL _ILIsFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:1951
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PathFindExtension
Definition: shlwapi.h:907
static const WCHAR L[]
Definition: oid.c:1250
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:1960
#define ERR(fmt,...)
Definition: debug.h:109
FileStructW * _ILGetFileStructW(LPCITEMIDLIST pidl)
Definition: pidl.c:2336
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
WCHAR * LPWSTR
Definition: xmlstorage.h:184
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by CDesktopFolder::GetUIObjectOf(), and CFSFolder::GetUIObjectOf().

◆ GetNextElementW()

LPCWSTR GetNextElementW ( LPCWSTR  pszNext,
LPWSTR  pszOut,
DWORD  dwOut 
)

Definition at line 43 of file shlfolder.cpp.

44 {
45  LPCWSTR pszTail = pszNext;
46  DWORD dwCopy;
47 
48  TRACE ("(%s %p 0x%08x)\n", debugstr_w (pszNext), pszOut, dwOut);
49 
50  *pszOut = 0x0000;
51 
52  if (!pszNext || !*pszNext)
53  return NULL;
54 
55  while (*pszTail && (*pszTail != (WCHAR) '\\'))
56  pszTail++;
57 
58  dwCopy = pszTail - pszNext + 1;
59  lstrcpynW (pszOut, pszNext, (dwOut < dwCopy) ? dwOut : dwCopy);
60 
61  if (*pszTail)
62  pszTail++;
63  else
64  pszTail = NULL;
65 
66  TRACE ("--(%s %s 0x%08x %p)\n", debugstr_w (pszNext), debugstr_w (pszOut), dwOut, pszTail);
67  return pszTail;
68 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define lstrcpynW
Definition: compat.h:397
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by CFSFolder::ParseDisplayName().

◆ SH_GetApidlFromDataObject()

HRESULT SH_GetApidlFromDataObject ( IDataObject pDataObject,
PIDLIST_ABSOLUTE ppidlfolder,
PUITEMID_CHILD **  apidlItems,
UINT pcidl 
)

Definition at line 327 of file shlfolder.cpp.

328 {
330  if (!cfShellIDList)
331  return E_FAIL;
332 
333  FORMATETC fmt;
334  InitFormatEtc (fmt, cfShellIDList, TYMED_HGLOBAL);
335 
336  HRESULT hr = pDataObject->QueryGetData(&fmt);
337  if (FAILED_UNEXPECTEDLY(hr))
338  return hr;
339 
340  STGMEDIUM medium;
341  hr = pDataObject->GetData(&fmt, &medium);
342  if (FAILED_UNEXPECTEDLY(hr))
343  return hr;
344 
345  /* lock the handle */
346  LPIDA lpcida = (LPIDA)GlobalLock(medium.hGlobal);
347  if (!lpcida)
348  {
349  ReleaseStgMedium(&medium);
350  return E_FAIL;
351  }
352 
353  /* convert the data into pidl */
354  LPITEMIDLIST pidl;
355  LPITEMIDLIST *apidl = _ILCopyCidaToaPidl(&pidl, lpcida);
356  if (!apidl)
357  {
358  ReleaseStgMedium(&medium);
359  return E_OUTOFMEMORY;
360  }
361 
362  *ppidlfolder = pidl;
363  *apidlItems = apidl;
364  *pcidl = lpcida->cidl;
365 
366  ReleaseStgMedium(&medium);
367  return S_OK;
368 }
#define CFSTR_SHELLIDLIST
Definition: shlobj.h:469
HRESULT hr
Definition: shlfolder.c:183
#define InitFormatEtc(fe, cf, med)
Definition: editor.h:33
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2036
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
const char * fmt
Definition: wsprintf.c:30
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
#define E_FAIL
Definition: ddrawi.h:102
LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST *pidl, const CIDA *cida)
Definition: pidl.c:2659
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
struct CIDA * LPIDA
UINT cidl
Definition: shlobj.h:491
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define S_OK
Definition: intsafe.h:59
HRESULT QueryGetData([in, unique] FORMATETC *pformatetc)
unsigned int UINT
Definition: ndis.h:50
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
Definition: dsound.c:943
Definition: shlobj.h:490

Referenced by CFSDropTarget::_RepositionItems(), DrivesContextMenuCallback(), RegFolderContextMenuCallback(), and Shell_DefaultContextMenuCallBack().

◆ SHCreateLinks()

HRESULT WINAPI SHCreateLinks ( HWND  hWnd,
LPCSTR  lpszDir,
IDataObject lpDataObject,
UINT  uFlags,
LPITEMIDLIST lppidlLinks 
)

Definition at line 375 of file shlfolder.cpp.

377 {
378  FIXME("%p %s %p %08x %p\n", hWnd, lpszDir, lpDataObject, uFlags, lppidlLinks);
379  return E_NOTIMPL;
380 }
HWND hWnd
Definition: settings.c:17
UINT uFlags
Definition: api.c:60
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ SHELL32_BindToSF()

HRESULT SHELL32_BindToSF ( LPCITEMIDLIST  pidlRoot,
PERSIST_FOLDER_TARGET_INFO *  ppfti,
LPCITEMIDLIST  pidl,
const GUID clsid,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 159 of file shlfolder.cpp.

161 {
162  PITEMID_CHILD pidlChild = ILCloneFirst (pidl);
163  if (!pidlChild)
164  return E_FAIL;
165 
167  HRESULT hr = SHELL32_CoCreateInitSF(pidlRoot,
168  ppfti,
169  pidlChild,
170  clsid,
171  IID_PPV_ARG(IShellFolder, &psf));
172  ILFree(pidlChild);
173 
174  if (FAILED_UNEXPECTEDLY(hr))
175  return hr;
176 
177  if (_ILIsPidlSimple (pidl))
178  return psf->QueryInterface(riid, ppvOut);
179  else
180  return psf->BindToObject(ILGetNext (pidl), NULL, riid, ppvOut);
181 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
HRESULT SHELL32_CoCreateInitSF(LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO *ppfti, LPCITEMIDLIST pidlChild, const GUID *clsid, REFIID riid, LPVOID *ppvOut)
Definition: shlfolder.cpp:121
BOOL WINAPI _ILIsPidlSimple(LPCITEMIDLIST pidl)
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
REFCLSID clsid
Definition: msctf.c:84
LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl)
Definition: pidl.c:253

Referenced by CNetFolder::BindToObject(), CDrivesFolder::BindToObject(), CFSFolder::BindToObject(), and CRegFolder::BindToObject().

◆ SHELL32_CoCreateInitSF() [1/2]

HRESULT SHELL32_CoCreateInitSF ( LPCITEMIDLIST  pidlRoot,
PERSIST_FOLDER_TARGET_INFO *  ppfti,
LPCITEMIDLIST  pidlChild,
const GUID clsid,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 121 of file shlfolder.cpp.

123 {
124  HRESULT hr;
125  CComPtr<IShellFolder> pShellFolder;
126 
128  if (FAILED(hr))
129  return hr;
130 
131  LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild);
134 
135  if (ppfti && SUCCEEDED(pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder3, &ppf3))))
136  {
137  ppf3->InitializeEx(NULL, pidlAbsolute, ppfti);
138  }
139  else if (SUCCEEDED(pShellFolder->QueryInterface(IID_PPV_ARG(IPersistFolder, &ppf))))
140  {
141  ppf->Initialize(pidlAbsolute);
142  }
143  ILFree (pidlAbsolute);
144 
145  return pShellFolder->QueryInterface(riid, ppvOut);
146 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
#define IID_PPV_ARG(Itype, ppType)
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHCoCreateInstance(LPCWSTR aclsid, const CLSID *clsid, LPUNKNOWN pUnkOuter, REFIID refiid, LPVOID *ppv)
Definition: shellole.c:105
LONG HRESULT
Definition: typedefs.h:77
REFCLSID clsid
Definition: msctf.c:84
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by CDesktopFolder::FinalConstruct(), CAdminToolsFolder::Initialize(), CMyDocsFolder::Initialize(), CFontsFolder::Initialize(), SHELL32_BindToSF(), and SHELL32_CoCreateInitSF().

◆ SHELL32_CoCreateInitSF() [2/2]

HRESULT SHELL32_CoCreateInitSF ( LPCITEMIDLIST  pidlRoot,
const GUID clsid,
int  csidl,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 148 of file shlfolder.cpp.

150 {
151  /* fill the PERSIST_FOLDER_TARGET_INFO */
152  PERSIST_FOLDER_TARGET_INFO pfti = {0};
153  pfti.dwAttributes = -1;
154  pfti.csidl = csidl;
155 
156  return SHELL32_CoCreateInitSF(pidlRoot, &pfti, NULL, clsid, riid, ppvOut);
157 }
REFIID riid
Definition: precomp.h:44
smooth NULL
Definition: ftsmooth.c:416
HRESULT SHELL32_CoCreateInitSF(LPCITEMIDLIST pidlRoot, PERSIST_FOLDER_TARGET_INFO *ppfti, LPCITEMIDLIST pidlChild, const GUID *clsid, REFIID riid, LPVOID *ppvOut)
Definition: shlfolder.cpp:121
REFCLSID clsid
Definition: msctf.c:84

◆ SHELL32_CompareChildren()

HRESULT SHELL32_CompareChildren ( IShellFolder2 psf,
LPARAM  lParam,
LPCITEMIDLIST  pidl1,
LPCITEMIDLIST  pidl2 
)

Definition at line 215 of file shlfolder.cpp.

216 {
217  PUIDLIST_RELATIVE nextpidl1 = ILGetNext (pidl1);
218  PUIDLIST_RELATIVE nextpidl2 = ILGetNext (pidl2);
219 
220  bool isEmpty1 = _ILIsDesktop(nextpidl1);
221  bool isEmpty2 = _ILIsDesktop(nextpidl2);
222  if (isEmpty1 || isEmpty2)
223  return MAKE_COMPARE_HRESULT(isEmpty2 - isEmpty1);
224 
225  PITEMID_CHILD firstpidl = ILCloneFirst (pidl1);
226  if (!firstpidl)
227  return E_OUTOFMEMORY;
228 
230  HRESULT hr = psf->BindToObject(firstpidl, 0, IID_PPV_ARG(IShellFolder, &psf2));
231  ILFree(firstpidl);
232  if (FAILED(hr))
233  return MAKE_COMPARE_HRESULT(0);
234 
235  return psf2->CompareIDs(lParam, nextpidl1, nextpidl2);
236 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
ITEMIDLIST_RELATIVE UNALIGNED * PUIDLIST_RELATIVE
Definition: shtypes.idl:55
#define MAKE_COMPARE_HRESULT(x)
Definition: shellutils.h:380
#define IID_PPV_ARG(Itype, ppType)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
LONG HRESULT
Definition: typedefs.h:77
LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl)
Definition: pidl.c:253
LPARAM lParam
Definition: combotst.c:139

Referenced by CDrivesFolder::CompareIDs(), CFSFolder::CompareIDs(), CRegFolder::CompareIDs(), and SHELL32_CompareDetails().

◆ SHELL32_CompareDetails()

HRESULT SHELL32_CompareDetails ( IShellFolder2 isf,
LPARAM  lParam,
LPCITEMIDLIST  pidl1,
LPCITEMIDLIST  pidl2 
)

Definition at line 238 of file shlfolder.cpp.

239 {
241  WCHAR wszItem1[MAX_PATH], wszItem2[MAX_PATH];
242  HRESULT hres;
243 
244  hres = isf->GetDetailsOf(pidl1, lParam, &sd);
245  if (FAILED(hres))
246  return MAKE_COMPARE_HRESULT(1);
247 
248  hres = StrRetToBufW(&sd.str, pidl1, wszItem1, MAX_PATH);
249  if (FAILED(hres))
250  return MAKE_COMPARE_HRESULT(1);
251 
252  hres = isf->GetDetailsOf(pidl2, lParam, &sd);
253  if (FAILED(hres))
254  return MAKE_COMPARE_HRESULT(1);
255 
256  hres = StrRetToBufW(&sd.str, pidl2, wszItem2, MAX_PATH);
257  if (FAILED(hres))
258  return MAKE_COMPARE_HRESULT(1);
259 
260  int ret = wcsicmp(wszItem1, wszItem2);
261  if (ret == 0)
262  return SHELL32_CompareChildren(isf, lParam, pidl1, pidl2);
263 
264  return MAKE_COMPARE_HRESULT(ret);
265 }
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1522
#define MAKE_COMPARE_HRESULT(x)
Definition: shellutils.h:380
HRESULT SHELL32_CompareChildren(IShellFolder2 *psf, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: shlfolder.cpp:215
HRESULT GetDetailsOf([in] PCUITEMID_CHILD pidl, [in] UINT iColumn, [out] SHELLDETAILS *psd)
HRESULT hres
Definition: protocol.c:465
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
static const WCHAR sd[]
Definition: suminfo.c:287
int ret
#define wcsicmp
Definition: string.h:1152
LPARAM lParam
Definition: combotst.c:139

Referenced by CControlPanelFolder::CompareIDs(), CDrivesFolder::CompareIDs(), CPrinterFolder::CompareIDs(), CFSFolder::CompareIDs(), and CRegFolder::CompareIDs().

◆ SHELL32_GetDisplayNameOfChild()

HRESULT SHELL32_GetDisplayNameOfChild ( IShellFolder2 psf,
LPCITEMIDLIST  pidl,
DWORD  dwFlags,
LPSTRRET  strRet 
)

Definition at line 197 of file shlfolder.cpp.

199 {
200  LPITEMIDLIST pidlFirst = ILCloneFirst(pidl);
201  if (!pidlFirst)
202  return E_OUTOFMEMORY;
203 
204  CComPtr<IShellFolder> psfChild;
205  HRESULT hr = psf->BindToObject(pidlFirst, NULL, IID_PPV_ARG(IShellFolder, &psfChild));
206  if (SUCCEEDED (hr))
207  {
208  hr = psfChild->GetDisplayNameOf(ILGetNext (pidl), dwFlags, strRet);
209  }
210  ILFree (pidlFirst);
211 
212  return hr;
213 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
#define IID_PPV_ARG(Itype, ppType)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
LONG HRESULT
Definition: typedefs.h:77
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl)
Definition: pidl.c:253
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by CDrivesFolder::GetDisplayNameOf(), CDesktopFolder::GetDisplayNameOf(), CFSFolder::GetDisplayNameOf(), and CRegFolder::GetDisplayNameOf().

◆ SHELL32_ParseNextElement()

HRESULT SHELL32_ParseNextElement ( IShellFolder2 psf,
HWND  hwndOwner,
LPBC  pbc,
LPITEMIDLIST pidlInOut,
LPOLESTR  szNext,
DWORD pEaten,
DWORD pdwAttributes 
)

Definition at line 70 of file shlfolder.cpp.

72 {
74  LPITEMIDLIST pidlIn = pidlInOut ? *pidlInOut : NULL;
75  LPITEMIDLIST pidlOut = NULL;
76  LPITEMIDLIST pidlTemp = NULL;
77  CComPtr<IShellFolder> psfChild;
78 
79  TRACE ("(%p, %p, %p, %s)\n", psf, pbc, pidlIn, debugstr_w (szNext));
80 
81  /* get the shellfolder for the child pidl and let it analyse further */
82  hr = psf->BindToObject(pidlIn, pbc, IID_PPV_ARG(IShellFolder, &psfChild));
83  if (FAILED(hr))
84  return hr;
85 
86  hr = psfChild->ParseDisplayName(hwndOwner, pbc, szNext, pEaten, &pidlOut, pdwAttributes);
87  if (FAILED(hr))
88  return hr;
89 
90  pidlTemp = ILCombine (pidlIn, pidlOut);
91  if (!pidlTemp)
92  {
93  hr = E_OUTOFMEMORY;
94  if (pidlOut)
95  ILFree(pidlOut);
96  return hr;
97  }
98 
99  if (pidlOut)
100  ILFree (pidlOut);
101 
102  if (pidlIn)
103  ILFree (pidlIn);
104 
105  *pidlInOut = pidlTemp;
106 
107  TRACE ("-- pidl=%p ret=0x%08x\n", pidlInOut ? *pidlInOut : NULL, hr);
108  return S_OK;
109 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
#define IID_PPV_ARG(Itype, ppType)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by CDrivesFolder::ParseDisplayName(), CDesktopFolder::ParseDisplayName(), CFSFolder::ParseDisplayName(), and CRegFolder::ParseDisplayName().

◆ Shell_DefaultContextMenuCallBack()

HRESULT WINAPI Shell_DefaultContextMenuCallBack ( IShellFolder psf,
IDataObject pdtobj 
)

Definition at line 450 of file shlfolder.cpp.

451 {
452  PIDLIST_ABSOLUTE pidlFolder;
453  PUITEMID_CHILD *apidl;
454  UINT cidl;
455  HRESULT hr = SH_GetApidlFromDataObject(pdtobj, &pidlFolder, &apidl, &cidl);
456  if (FAILED_UNEXPECTEDLY(hr))
457  return hr;
458 
459  if (cidl > 1)
460  {
461  ERR("SHMultiFileProperties is not yet implemented\n");
462  SHFree(pidlFolder);
463  _ILFreeaPidl(apidl, cidl);
464  return E_FAIL;
465  }
466 
467  STRRET strFile;
468  hr = psf->GetDisplayNameOf(apidl[0], SHGDN_FORPARSING, &strFile);
469  if (SUCCEEDED(hr))
470  {
471  hr = SH_ShowPropertiesDialog(strFile.pOleStr, pidlFolder, apidl);
472  if (FAILED(hr))
473  ERR("SH_ShowPropertiesDialog failed\n");
474  }
475  else
476  {
477  ERR("Failed to get display name\n");
478  }
479 
480  SHFree(pidlFolder);
481  _ILFreeaPidl(apidl, cidl);
482 
483  return hr;
484 }
HRESULT hr
Definition: shlfolder.c:183
ITEMID_CHILD UNALIGNED * PUITEMID_CHILD
Definition: shtypes.idl:68
LPWSTR pOleStr
Definition: shtypes.idl:96
#define E_FAIL
Definition: ddrawi.h:102
HRESULT GetDisplayNameOf([in] PCUITEMID_CHILD pidl, [in] SHGDNF uFlags, [out] STRRET *lpName)
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
BOOL SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, PCUITEMID_CHILD_ARRAY apidl)
Definition: fprop.cpp:94
HRESULT SH_GetApidlFromDataObject(IDataObject *pDataObject, PIDLIST_ABSOLUTE *ppidlfolder, PUITEMID_CHILD **apidlItems, UINT *pcidl)
Definition: shlfolder.cpp:327
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2621
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int UINT
Definition: ndis.h:50
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by CDrivesFolder::CallBack(), CDesktopFolder::CallBack(), and CFSFolder::CallBack().

◆ SHOpenFolderAndSelectItems()

EXTERN_C HRESULT WINAPI SHOpenFolderAndSelectItems ( LPITEMIDLIST  pidlFolder,
UINT  cidl,
PCUITEMID_CHILD_ARRAY  apidl,
DWORD  dwFlags 
)

Definition at line 389 of file shlfolder.cpp.

393 {
394  ERR("SHOpenFolderAndSelectItems() is hackplemented\n");
395  PCIDLIST_ABSOLUTE pidlItem;
396  if (cidl)
397  {
398  /* Firefox sends a full pidl here dispite the fact it is a PCUITEMID_CHILD_ARRAY -_- */
399  if (ILGetNext(apidl[0]) != NULL)
400  {
401  pidlItem = apidl[0];
402  }
403  else
404  {
405  pidlItem = ILCombine(pidlFolder, apidl[0]);
406  }
407  }
408  else
409  {
410  pidlItem = pidlFolder;
411  }
412 
413  CComPtr<IShellFolder> psfDesktop;
414 
415  HRESULT hr = SHGetDesktopFolder(&psfDesktop);
416  if (FAILED_UNEXPECTEDLY(hr))
417  return hr;
418 
419  STRRET strret;
420  hr = psfDesktop->GetDisplayNameOf(pidlItem, SHGDN_FORPARSING, &strret);
421  if (FAILED_UNEXPECTEDLY(hr))
422  return hr;
423 
424  WCHAR wszBuf[MAX_PATH];
425  hr = StrRetToBufW(&strret, pidlItem, wszBuf, _countof(wszBuf));
426  if (FAILED_UNEXPECTEDLY(hr))
427  return hr;
428 
429  WCHAR wszParams[MAX_PATH];
430  wcscpy(wszParams, L"/select,");
431  wcscat(wszParams, wszBuf);
432 
433  SHELLEXECUTEINFOW sei;
434  memset(&sei, 0, sizeof sei);
435  sei.cbSize = sizeof sei;
437  sei.lpFile = L"explorer.exe";
438  sei.lpParameters = wszParams;
439 
440  if (ShellExecuteExW(&sei))
441  return S_OK;
442  else
443  return E_FAIL;
444 }
HRESULT hr
Definition: shlfolder.c:183
#define SEE_MASK_WAITFORINPUTIDLE
Definition: shellapi.h:56
#define _countof(array)
Definition: fontsub.cpp:30
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1522
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2225
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
#define MAX_PATH
Definition: compat.h:26
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
LPCWSTR lpParameters
Definition: shellapi.h:331
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define memset(x, y, z)
Definition: compat.h:39

Referenced by CShellLink::OnCommand().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )