Introduction
This is a class helps you manage ITEMIDLIST
easier
. The
CItemIDList
class holds a pointer to a ITEMIDLIST
structure
(the pointer is in CItemIDList::m_pidl
). It also has public static
member functions which you can use as global functions.(Version 2.0)
Constructors
CItemIDList(LPCTSTR pcszPath);
|
Construct with a path string. |
CItemIDList(LPITEMIDLIST pidl);
|
Construct with LPITEMIDLIST .(Copy it,and free on destruct) |
CItemIDList(CItemIDList& iidl);
|
Construct with another class object. |
CItemIDList(void);
|
Construct class instance with m_pidl empty. |
Member functions
int GetIconIndex(void) const;
|
Get folder item's icon index in system image list. |
BOOL GetDisplayName(LPTSTR pszBuf,DWORD dwFlags=SHGDN_NORMAL)
const;
|
Retrieve pidl's dislpay name. |
CItemIDList Duplicate(UINT nCount=-1) const;
|
Copy a pidl due to the count number. |
inline BOOL IsEmpty(void) const;
|
Whether m_pidl is NULL . |
CItemIDList GetAt(UINT nIndex) const;
|
Return a relative pidl at specified index. |
BOOL Create(LPITEMIDLIST pidlf);
|
Create from a LPITEMIDLIST . |
inline UINT GetCount(void) const;
|
Get pidl count. |
inline UINT GetSize(void) const;
|
Get pidl's size,in byte. |
inline void Empty(void);
|
Free m_pidl and set to NULL . |
void GetPath(LPTSTR pszPath) const;
|
Retrieve full path.(only available for full-quality pidl) |
inline HRESULT GetUIObjectOf(REFIID riid,LPVOID* ppOut,HWND
hWnd=NULL);
|
Retrieve other shell interface.Same as IShellFolder::GetUIObjectOf. |
inline void Split(LPSHELLFOLDER& lpsf,CItemIDList&
ciid) const;
|
Get IShellFolder interface and the tail pidl cell from a full-quality
pidl. |
CItemIDList GetLastPidl(void) const;
|
Retrieve the tail pidl cell. |
void GetToolTipInfo(LPTSTR pszToolTip,UINT cbSize) const;
|
Retrieve the tooltip info of the m_pidl. |
void Attach(LPITEMIDLIST pidl);
|
Attach a pidl. |
LPITEMIDLIST Detach(void);
|
Detach a pidl. |
Operators
CItemIDList operator+(CItemIDList& piidl);
|
Concat two pidls. |
operator LPITEMIDLIST(void) const;
|
Get m_pidl . |
operator LPCITEMIDLIST(void) const;
|
Get m_pidl convert to LPCITEMIDLIST. |
const CItemIDList& operator=(CItemIDList& ciidl1);
|
Copy from another class instance. |
const CItemIDList& operator=(LPITEMIDLIST pidl);
|
Copy from a LPITEMIDLIST . |
operator+=(CItemIDList& ciidl);
|
Add a new pidl to m_pidl 's tail. |
BOOL operator==(CItemIDList& ciidl);
|
Query whether two pidl's name is same. |
CItemIDList operator[](UINT nIndex);
|
Return a relative pidl at specified index.(Same as CItemIDList::GetAt(UINT
nIndex) ) |
Example
#include "ItemIDList.h"
#include <windows.h>
#include <iostream.h>
void main()
{
char szFile[MAX_PATH];
ZeroMemory(szFile,MAX_PATH);
OPENFILENAME info;
ZeroMemory(&info,sizeof(info));
info.lStructSize=sizeof(info);
info.lpstrFile=szFile;
info.hwndOwner=NULL;
info.nMaxFile=MAX_PATH;
if(GetOpenFileName(&info))
{
CItemIDList item(szFile),item2;
char szName[MAX_PATH];
item.GetDisplayName(szName);
cout<<szName<<endl;
item.GetToolTipInfo(szName,MAX_PATH);
cout<<szName<<endl;
item2=item;
item2.GetPath(szName);
cout<<szName<<endl;
item2=item[item.GetCount()-1];
item2.GetDisplayName(szName);
cout<<szName<<endl;
item2=item.GetAt(0);
item2.GetDisplayName(szName);
cout<<szName<<endl;
CItemIDList item3;
item3=item.Duplicate(item.GetCount()-1);
item3.GetPath(szName);
cout<<szName<<endl;
item3=item.Duplicate(item.GetCount()-1)+item2;
item3.GetPath(szName);
cout<<szName<<endl;
}
}
Enjoy...