ReactOS  0.4.13-dev-99-g7e18b6d
CShellItem.cpp File Reference
#include "precomp.h"
Include dependency graph for CShellItem.cpp:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
EXTERN_C HRESULT WINAPI SHCreateShellItem (LPCITEMIDLIST pidlParent, IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi)
 

Function Documentation

◆ SHCreateShellItem()

HRESULT WINAPI SHCreateShellItem ( LPCITEMIDLIST  pidlParent,
IShellFolder psfParent,
LPCITEMIDLIST  pidl,
IShellItem **  ppsi 
)

Definition at line 264 of file CShellItem.cpp.

266 {
267  HRESULT hr;
268  CComPtr<IShellItem> newShellItem;
269  LPITEMIDLIST new_pidl;
270  CComPtr<IPersistIDList> newPersistIDList;
271 
272  TRACE("(%p,%p,%p,%p)\n", pidlParent, psfParent, pidl, ppsi);
273 
274  *ppsi = NULL;
275 
276  if (!pidl)
277  return E_INVALIDARG;
278 
279  if (pidlParent || psfParent)
280  {
281  LPITEMIDLIST temp_parent = NULL;
282  if (!pidlParent)
283  {
284  CComPtr<IPersistFolder2> ppf2Parent;
285 
286  if (FAILED(psfParent->QueryInterface(IID_PPV_ARG(IPersistFolder2, &ppf2Parent))))
287  {
288  FIXME("couldn't get IPersistFolder2 interface of parent\n");
289  return E_NOINTERFACE;
290  }
291 
292  if (FAILED(ppf2Parent->GetCurFolder(&temp_parent)))
293  {
294  FIXME("couldn't get parent PIDL\n");
295  return E_NOINTERFACE;
296  }
297 
298  pidlParent = temp_parent;
299  }
300 
301  new_pidl = ILCombine(pidlParent, pidl);
302  ILFree(temp_parent);
303 
304  if (!new_pidl)
305  return E_OUTOFMEMORY;
306  }
307  else
308  {
309  new_pidl = ILClone(pidl);
310  if (!new_pidl)
311  return E_OUTOFMEMORY;
312  }
313 
314  hr = CShellItem::_CreatorClass::CreateInstance(NULL, IID_PPV_ARG(IShellItem, &newShellItem));
315  if (FAILED(hr))
316  {
317  ILFree(new_pidl);
318  return hr;
319  }
320  hr = newShellItem->QueryInterface(IID_PPV_ARG(IPersistIDList, &newPersistIDList));
321  if (FAILED(hr))
322  {
323  ILFree(new_pidl);
324  return hr;
325  }
326  hr = newPersistIDList->SetIDList(new_pidl);
327  if (FAILED(hr))
328  {
329  ILFree(new_pidl);
330  return hr;
331  }
332  ILFree(new_pidl);
333 
334  *ppsi = newShellItem.Detach();
335 
336  return hr;
337 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define E_NOINTERFACE
Definition: winerror.h:2364
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 FIXME(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
T * Detach()
Definition: atlcomcli.h:156
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by CShellItem::GetParent(), and init_function_pointers().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )