1 ////////////////////////////////////////////////////////////////////
2 // PIDL.h: interface for the CPIDL class.
15 // == Construction/Destruction == //
17 CPIDL() : m_pidl(NULL) {}
20 CPIDL(const CPIDL& cpidl) : m_pidl(NULL) { Set(cpidl); }
22 // From path (szPath relative to the folder psf) - see Set()
23 CPIDL(LPCTSTR szPath, LPSHELLFOLDER psf = m_sfDesktop);
25 // From a list ptr - *doesn't* copy the actual data - see Set()
26 CPIDL(LPITEMIDLIST pidl) : m_pidl(pidl) {}
31 // == Assignment == //
33 // Make a copy of cpidl's list data
34 HRESULT Set(const CPIDL& cpidl);
36 // Set by path: szPath relative to the folder psf.
37 HRESULT Set(LPCTSTR szPath, LPSHELLFOLDER psf = m_sfDesktop);
39 // Points the CPIDL to an existing item list: does *not* copy
40 // the actual data - just the pointer (unlike MakeCopyOf()).
41 HRESULT Set(LPITEMIDLIST pidl);
43 // Special Assignment: Copies the data of an exisiting list.
44 HRESULT MakeCopyOf(LPITEMIDLIST pidl);
46 // Special Assignment: Makes a PIDL rooted at the desktop.
47 HRESULT MakeAbsPIDLOf(LPSHELLFOLDER psf, LPITEMIDLIST pidl);
50 // == Item Access == //
52 // Returns a pointer to the first item in the list
53 LPSHITEMID GetFirstItemID() const { return (LPSHITEMID)m_pidl; }
55 // Points to the next item in the list
56 void GetNextItemID(LPSHITEMID& pid) const
57 { (LPBYTE &)pid += pid->cb; }
60 // == General Operations == //
62 void Free(); // Frees the memory used by the item id list
63 UINT GetSize() const; // Counts the actual memory in use
65 // Split into direct parent and object pidls
66 void Split(CPIDL& parent, CPIDL& obj) const;
69 CPIDL operator + (CPIDL& pidl) const; // using + operator
70 static void Concat(const CPIDL &a, const CPIDL& b,
71 CPIDL& result); // result = a+b (faster)
74 // == Shell Name-space Access Helper Functions == //
76 // 1) Won't always work: psf->GetUIObjectOf(pidl, ... )
77 // 2) Will always work: pidl.GetUIObjectOf(..., psf)
78 HRESULT GetUIObjectOf(REFIID riid, LPVOID *ppvOut,
79 HWND hWnd = NULL, LPSHELLFOLDER psf = m_sfDesktop);
81 // Places the STRRET string in the cStr field.
82 void ExtractCStr(STRRET& strRet) const;
85 // == Conversion Operators == //
87 operator LPITEMIDLIST& () { return m_pidl; }
88 operator LPITEMIDLIST * () { return &m_pidl; }
89 operator LPCITEMIDLIST () const { return m_pidl; }
90 operator LPCITEMIDLIST* () const
91 { return (LPCITEMIDLIST *)&m_pidl; }
94 static LPSHELLFOLDER m_sfDesktop; // desktop object
95 static LPMALLOC m_pAllocator; // system allocator
97 // allocate memory for the pidl using the system allocator
98 void AllocMem(int iAllocSize);
100 // initializer (used for automatic initialization)
101 static struct pidl_initializer {
105 friend struct pidl_initializer;