ReactOS  0.4.14-dev-358-gbef841c
CShellItem Class Reference

#include <CShellItem.h>

Inheritance diagram for CShellItem:
Collaboration diagram for CShellItem:

Public Member Functions

 CShellItem ()
 
 ~CShellItem ()
 
HRESULT get_parent_pidl (LPITEMIDLIST *parent_pidl)
 
HRESULT get_parent_shellfolder (IShellFolder **ppsf)
 
HRESULT get_shellfolder (IBindCtx *pbc, REFIID riid, void **ppvOut)
 
virtual HRESULT WINAPI BindToHandler (IBindCtx *pbc, REFGUID rbhid, REFIID riid, void **ppvOut)
 
virtual HRESULT WINAPI GetParent (IShellItem **ppsi)
 
virtual HRESULT WINAPI GetDisplayName (SIGDN sigdnName, LPWSTR *ppszName)
 
virtual HRESULT WINAPI GetAttributes (SFGAOF sfgaoMask, SFGAOF *psfgaoAttribs)
 
virtual HRESULT WINAPI Compare (IShellItem *oth, SICHINTF hint, int *piOrder)
 
virtual HRESULT WINAPI GetClassID (CLSID *pClassID)
 
virtual HRESULT WINAPI SetIDList (PCIDLIST_ABSOLUTE pidl)
 
virtual HRESULT WINAPI GetIDList (PIDLIST_ABSOLUTE *ppidl)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Private Attributes

LPITEMIDLIST m_pidl
 

Additional Inherited Members

- Public Types inherited from IShellItem
enum  SIGDN {
  SIGDN_NORMALDISPLAY = 0, SIGDN_PARENTRELATIVEPARSING = 0x80018001, SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000, SIGDN_PARENTRELATIVEEDITING = 0x80031001,
  SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000, SIGDN_FILESYSPATH = 0x80058000, SIGDN_URL = 0x80068000, SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8007c001,
  SIGDN_PARENTRELATIVE = 0x80080001
}
 
enum  _SICHINTF { SICHINT_DISPLAY = 0x00000000, SICHINT_CANONICAL = 0x10000000, SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL = 0x20000000, SICHINT_ALLFIELDS = 0x80000000 }
 
typedef DWORD SICHINTF
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IPersist
typedef IPersistLPPERSIST
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 25 of file CShellItem.h.

Constructor & Destructor Documentation

◆ CShellItem()

CShellItem::CShellItem ( )

Definition at line 30 of file CShellItem.cpp.

30  :
31  m_pidl(NULL)
32 {
33 }
smooth NULL
Definition: ftsmooth.c:416
LPITEMIDLIST m_pidl
Definition: CShellItem.h:32

◆ ~CShellItem()

CShellItem::~CShellItem ( )

Definition at line 35 of file CShellItem.cpp.

36 {
37  ILFree(m_pidl);
38 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
LPITEMIDLIST m_pidl
Definition: CShellItem.h:32

Member Function Documentation

◆ BindToHandler()

HRESULT WINAPI CShellItem::BindToHandler ( IBindCtx pbc,
REFGUID  rbhid,
REFIID  riid,
void **  ppvOut 
)
virtual

Implements IShellItem.

Definition at line 101 of file CShellItem.cpp.

102 {
103  HRESULT ret;
104  TRACE("(%p, %p,%s,%p,%p)\n", this, pbc, shdebugstr_guid(&rbhid), riid, ppvOut);
105 
106  *ppvOut = NULL;
107  if (IsEqualGUID(rbhid, BHID_SFObject))
108  {
109  return get_shellfolder(pbc, riid, ppvOut);
110  }
111  else if (IsEqualGUID(rbhid, BHID_SFUIObject))
112  {
113  CComPtr<IShellFolder> psf_parent;
114  if (_ILIsDesktop(m_pidl))
115  ret = SHGetDesktopFolder(&psf_parent);
116  else
117  ret = get_parent_shellfolder(&psf_parent);
119  return ret;
120 
122  return psf_parent->GetUIObjectOf(NULL, 1, &pidl, riid, NULL, ppvOut);
123  }
124  else if (IsEqualGUID(rbhid, BHID_DataObject))
125  {
126  return BindToHandler(pbc, BHID_SFUIObject, IID_IDataObject, ppvOut);
127  }
128  else if (IsEqualGUID(rbhid, BHID_SFViewObject))
129  {
133  return ret;
134 
135  return psf->CreateViewObject(NULL, riid, ppvOut);
136  }
137 
138  FIXME("Unsupported BHID %s.\n", debugstr_guid(&rbhid));
139 
140  return MK_E_NOOBJECT;
141 }
REFIID riid
Definition: precomp.h:44
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
const char * shdebugstr_guid(const struct _GUID *id)
Definition: debughlp.cpp:414
const GUID IID_IDataObject
#define IID_PPV_ARG(Itype, ppType)
virtual HRESULT WINAPI BindToHandler(IBindCtx *pbc, REFGUID rbhid, REFIID riid, void **ppvOut)
Definition: CShellItem.cpp:101
#define FIXME(fmt,...)
Definition: debug.h:110
HRESULT get_shellfolder(IBindCtx *pbc, REFIID riid, void **ppvOut)
Definition: CShellItem.cpp:79
smooth NULL
Definition: ftsmooth.c:416
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
#define debugstr_guid
Definition: kernel32.h:35
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LPITEMIDLIST m_pidl
Definition: CShellItem.h:32
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
int ret
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
HRESULT get_parent_shellfolder(IShellFolder **ppsf)
Definition: CShellItem.cpp:61
#define MK_E_NOOBJECT
Definition: winerror.h:2786

◆ Compare()

HRESULT WINAPI CShellItem::Compare ( IShellItem oth,
SICHINTF  hint,
int piOrder 
)
virtual

Implements IShellItem.

Definition at line 191 of file CShellItem.cpp.

192 {
193  HRESULT hr;
194  CComPtr<IPersistIDList> pIDList;
195  CComPtr<IShellFolder> psfDesktop;
196  LPITEMIDLIST pidl;
197 
198  TRACE("(%p,%p,%x,%p)\n", this, oth, hint, piOrder);
199 
200  if (piOrder == NULL || oth == NULL)
201  return E_POINTER;
202 
203  hr = oth->QueryInterface(IID_PPV_ARG(IPersistIDList, &pIDList));
204  if (SUCCEEDED(hr))
205  {
206  hr = pIDList->GetIDList(&pidl);
207  if (SUCCEEDED(hr))
208  {
209  hr = SHGetDesktopFolder(&psfDesktop);
210  if (SUCCEEDED(hr))
211  {
212  hr = psfDesktop->CompareIDs(hint, m_pidl, pidl);
213  *piOrder = (int)(short)SCODE_CODE(hr);
214  }
215  ILFree(pidl);
216  }
217  }
218 
219  if(FAILED(hr))
220  return hr;
221 
222  if(*piOrder)
223  return S_FALSE;
224  else
225  return S_OK;
226 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LPITEMIDLIST m_pidl
Definition: CShellItem.h:32
LONG HRESULT
Definition: typedefs.h:77
#define S_OK
Definition: intsafe.h:59
DWORD hint
Definition: vfdcmd.c:88
#define SCODE_CODE(sc)
Definition: winerror.h:77
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define E_POINTER
Definition: winerror.h:2365
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define SUCCEEDED(hr)
Definition: intsafe.h:57
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

◆ get_parent_pidl()

HRESULT CShellItem::get_parent_pidl ( LPITEMIDLIST parent_pidl)

Definition at line 40 of file CShellItem.cpp.

41 {
42  *parent_pidl = ILClone(m_pidl);
43  if (*parent_pidl)
44  {
45  if (ILRemoveLastID(*parent_pidl))
46  return S_OK;
47  else
48  {
49  ILFree(*parent_pidl);
50  *parent_pidl = NULL;
51  return E_INVALIDARG;
52  }
53  }
54  else
55  {
56  *parent_pidl = NULL;
57  return E_OUTOFMEMORY;
58  }
59 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:212
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
LPITEMIDLIST m_pidl
Definition: CShellItem.h:32
#define S_OK
Definition: intsafe.h:59
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228

Referenced by get_parent_shellfolder(), and GetParent().

◆ get_parent_shellfolder()

HRESULT CShellItem::get_parent_shellfolder ( IShellFolder **  ppsf)

Definition at line 61 of file CShellItem.cpp.

62 {
63  HRESULT hr;
64  LPITEMIDLIST parent_pidl;
65  CComPtr<IShellFolder> desktop;
66 
67  hr = get_parent_pidl(&parent_pidl);
68  if (SUCCEEDED(hr))
69  {
70  hr = SHGetDesktopFolder(&desktop);
71  if (SUCCEEDED(hr))
72  hr = desktop->BindToObject(parent_pidl, NULL, IID_PPV_ARG(IShellFolder, ppsf));
73  ILFree(parent_pidl);
74  }
75 
76  return hr;
77 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
HRESULT get_parent_pidl(LPITEMIDLIST *parent_pidl)
Definition: CShellItem.cpp:40
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LONG HRESULT
Definition: typedefs.h:77
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by BindToHandler(), and GetAttributes().

◆ get_shellfolder()

HRESULT CShellItem::get_shellfolder ( IBindCtx pbc,
REFIID  riid,
void **  ppvOut 
)

Definition at line 79 of file CShellItem.cpp.

80 {
82  CComPtr<IShellFolder> psfDesktop;
83  HRESULT ret;
84 
85  ret = SHGetDesktopFolder(&psfDesktop);
87  return ret;
88 
89  if (_ILIsDesktop(m_pidl))
90  psf = psfDesktop;
91  else
92  {
93  ret = psfDesktop->BindToObject(m_pidl, pbc, IID_PPV_ARG(IShellFolder, &psf));
95  return ret;
96  }
97 
98  return psf->QueryInterface(riid, ppvOut);
99 }
REFIID riid
Definition: precomp.h:44
#define IID_PPV_ARG(Itype, ppType)
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LPITEMIDLIST m_pidl
Definition: CShellItem.h:32
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
int ret

Referenced by BindToHandler().

◆ GetAttributes()

HRESULT WINAPI CShellItem::GetAttributes ( SFGAOF  sfgaoMask,
SFGAOF psfgaoAttribs 
)
virtual

Implements IShellItem.

Definition at line 165 of file CShellItem.cpp.

166 {
167  CComPtr<IShellFolder> parent_folder;
168  LPCITEMIDLIST child_pidl;
169  HRESULT hr;
170 
171  TRACE("(%p,%x,%p)\n", this, sfgaoMask, psfgaoAttribs);
172 
173  if (_ILIsDesktop(m_pidl))
174  hr = SHGetDesktopFolder(&parent_folder);
175  else
176  hr = get_parent_shellfolder(&parent_folder);
177  if (FAILED_UNEXPECTEDLY(hr))
178  return hr;
179 
180  child_pidl = ILFindLastID(m_pidl);
181  *psfgaoAttribs = sfgaoMask;
182  hr = parent_folder->GetAttributesOf(1, &child_pidl, psfgaoAttribs);
183  *psfgaoAttribs &= sfgaoMask;
184 
185  if (FAILED_UNEXPECTEDLY(hr))
186  return hr;
187 
188  return (sfgaoMask == *psfgaoAttribs) ? S_OK : S_FALSE;
189 }
HRESULT hr
Definition: shlfolder.c:183
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define S_FALSE
Definition: winerror.h:2357
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
LPITEMIDLIST m_pidl
Definition: CShellItem.h:32
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:71
#define S_OK
Definition: intsafe.h:59
HRESULT get_parent_shellfolder(IShellFolder **ppsf)
Definition: CShellItem.cpp:61

◆ GetClassID()

HRESULT WINAPI CShellItem::GetClassID ( CLSID pClassID)
virtual

Implements IPersist.

Definition at line 228 of file CShellItem.cpp.

229 {
230  TRACE("(%p,%p)\n", this, pClassID);
231 
232  *pClassID = CLSID_ShellItem;
233  return S_OK;
234 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59

◆ GetDisplayName()

HRESULT WINAPI CShellItem::GetDisplayName ( SIGDN  sigdnName,
LPWSTR ppszName 
)
virtual

Implements IShellItem.

Definition at line 160 of file CShellItem.cpp.

161 {
163 }
HRESULT WINAPI SHGetNameFromIDList(PCIDLIST_ABSOLUTE pidl, SIGDN sigdnName, PWSTR *ppszName)
Definition: pidl.c:1409
SIGDN sigdnName
Definition: shobjidl.idl:588
SIGDN PWSTR * ppszName
Definition: shobjidl.idl:588
LPITEMIDLIST m_pidl
Definition: CShellItem.h:32

◆ GetIDList()

HRESULT WINAPI CShellItem::GetIDList ( PIDLIST_ABSOLUTE ppidl)
virtual

Implements IPersistIDList.

Definition at line 253 of file CShellItem.cpp.

254 {
255  TRACE("(%p,%p)\n", this, ppidl);
256 
257  *ppidl = ILClone(m_pidl);
258  if (*ppidl)
259  return S_OK;
260  else
261  return E_OUTOFMEMORY;
262 }
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
LPITEMIDLIST m_pidl
Definition: CShellItem.h:32
#define S_OK
Definition: intsafe.h:59
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228

◆ GetParent()

HRESULT WINAPI CShellItem::GetParent ( IShellItem **  ppsi)
virtual

Implements IShellItem.

Definition at line 143 of file CShellItem.cpp.

144 {
145  HRESULT hr;
146  LPITEMIDLIST parent_pidl;
147 
148  TRACE("(%p,%p)\n", this, ppsi);
149 
150  hr = get_parent_pidl(&parent_pidl);
151  if (SUCCEEDED(hr))
152  {
153  hr = SHCreateShellItem(NULL, NULL, parent_pidl, ppsi);
154  ILFree(parent_pidl);
155  }
156 
157  return hr;
158 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HRESULT hr
Definition: shlfolder.c:183
HRESULT get_parent_pidl(LPITEMIDLIST *parent_pidl)
Definition: CShellItem.cpp:40
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
EXTERN_C HRESULT WINAPI SHCreateShellItem(LPCITEMIDLIST pidlParent, IShellFolder *psfParent, LPCITEMIDLIST pidl, IShellItem **ppsi)
Definition: CShellItem.cpp:264
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ SetIDList()

HRESULT WINAPI CShellItem::SetIDList ( PCIDLIST_ABSOLUTE  pidl)
virtual

Implements IPersistIDList.

Definition at line 236 of file CShellItem.cpp.

237 {
238  LPITEMIDLIST new_pidl;
239 
240  TRACE("(%p,%p)\n", this, pidlx);
241 
242  new_pidl = ILClone(pidlx);
243  if (new_pidl)
244  {
245  ILFree(m_pidl);
246  m_pidl = new_pidl;
247  return S_OK;
248  }
249  else
250  return E_OUTOFMEMORY;
251 }
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define TRACE(s)
Definition: solgame.cpp:4
LPITEMIDLIST m_pidl
Definition: CShellItem.h:32
#define S_OK
Definition: intsafe.h:59
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Member Data Documentation

◆ m_pidl


The documentation for this class was generated from the following files: