I am trying to create a shell tree control. I do not want all the items that return from IShellFilder::EnumObjects
call to display on the tree as I need to filter items such as the Recycle Bin and the Control Panel for example.
My code looks like this:
IShellFolder* pDesktopFolder=NULL;
SHGetDesktopFolder(&pDesktopFolder);
LPITEMIDLIST pidlParent=NULL;
IShellFolder* pParentFolder = NULL;
pDesktopFolder->BindToObject(pidlParent,NULL, IID_IShellFolder, (LPVOID*)&pParentFolder);
IEnumIDList* pEnumIDList = NULL;
SHCONTF SHFlag=NULL;
SHFlag=SHCONTF_FOLDERS | SHCONTF_INIT_ON_FIRST_NEXT | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN;
HRESULT hr= pParentFolder->EnumObjects(NULL, SHFlag, &pEnumIDList);
if (NOERROR == hr)
{
LPITEMIDLIST pidl = NULL, pidlAbs;
CString csFileType;
HTREEITEM hItem=NULL;
while (NOERROR == pEnumIDList->Next(1, &pidl, NULL))
{
//Filter out control panel, recycle bin items and other non usable items
}
}
I don't want to get the display name of each item and do a string comparison on that since names can change depending on the OS language.
Can the filtering be done based on the CLSID of each item? And whats the best way of doing it?
Solved:
I did this and its working, yet I need to see where can I get a list of GUIDs for other folders:
ULONG nEaten=0;
LPITEMIDLIST PidlCPanel;
ULONG nCPAttrib = 0;
HRESULT hr = pFolder->ParseDisplayName(NULL, NULL, _T("::{26EE0668-A00A-44D7-9371-BEB064C98683}"), &nEaten, &PidlCPanel, &nCPAttrib);
BOOL bRes = ILIsEqual(pidl, PidlCPanel);