Reputation: 4775
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?
Upvotes: 3
Views: 2791
Reputation: 101616
When you have a IShellFolder and a child pidl you can use SHGetDataFromIDList(...,SHGDFIL_DESCRIPTIONID)
to get the CLSID of the pidl target.
See also:
Upvotes: 4
Reputation: 194
It seems if you only want to have real Filesystem items (just like BrowseForFolder), then you can use GetAttributesOf(..)
and check for SFGAO_FILESYSANCESTOR
, if it doesn't have the attribute, it isn't a filesystem item.. (zip files, control panel, recyclebin don't have the attribute)
Upvotes: 0
Reputation: 4775
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);
Upvotes: -1