Click here to Skip to main content
14,608,080 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to filter IShellFolder::EnumObjects result, by following instructions from this[^] question.

Although links from the highest voted answer are invalid, I was able to find them and apply Mr.Chen's code in my own. Everything worked fine for Recycle Bin, it was filtered out, but Control Panel stayed.

Below is the example code, with relevant comments. All I have changed was the constant CLSID_RecycleBin to CLSID_ControlPanel, everything else was the same.

HRESULT CShellTree::EnumObjects(HTREEITEM hParentItem, LPSHELLFOLDER pParentFolder, LPITEMIDLIST pidlParent)
        LPENUMIDLIST pEnum = NULL;

        HRESULT hr = pParentFolder->EnumObjects(NULL, m_dwFlags, &pEnum);
        if (FAILED(hr) || pEnum == NULL)
            return hr;

        LPITEMIDLIST pidlTemp;
        DWORD dwFetched = 1;

        while (SUCCEEDED(pEnum->Next(1, &pidlTemp, &dwFetched)) && dwFetched)
            IShellFolder* psf;
            LPCITEMIDLIST pidlChild;
            bool skip = false;

            hr = SHBindToParent(pidlTemp, IID_IShellFolder, (void**)&psf, &pidlChild);
            if (SUCCEEDED(hr))
                SHDESCRIPTIONID pdid;
                hr = SHGetDataFromIDList(psf, pidlChild, SHGDFIL_DESCRIPTIONID, &pdid, sizeof(pdid));
                if (SUCCEEDED(hr))
                    // below comparison fails, but it works for CLSID_RecycleBin
                    // when going through Debugger, pdid.clsid is {26EE0668-A00A-44D7-9371-BEB064C98683}
                    // CLSID_ControlPanel is {21EC2020-3AEA-1069-A2DD-08002B30309D}
                    skip = pdid.clsid == CLSID_ControlPanel;

            if (skip)
            // insert TreeView item, omitted for brevity
        return hr;


I am supporting Windows 8 onward, using VS 2019. For further info leave a comment.


How to make above CLSID comparison work? Where is the correct CLSID constant?

What I have tried:

Going through the Debugger, I saw that CLSID_ControlPanel has the value {21EC2020-3AEA-1069-A2DD-08002B30309D} but code returns {26EE0668-A00A-44D7-9371-BEB064C98683}, which is why comparison fails.

I have F12ed CLSID_RecycleBin hoping to find correct constant for Control Panel, but had no luck.

I have also looked here[^], but again had no success.

I have found this link[^] but can not yet see how will this info help me.

I am currently going through this SO question[^] as it seems relevant...
Richard MacCutchan 29-Jul-20 12:21pm
If you look at HKEY_CLASSES_ROOT/CLSID entries in the registry you will see that both of those keys refer to Control panel. Where is the definition for CLSID_ControlPanel that you are using?
RLebeau 29-Jul-20 12:40pm
CLSID_ControlPanel is defined in shlguid.h, but there are 3 other CLSIDs related to the ControlPanel which are not defined in the Win32 SDK headers:

{21EC2020-3AEA-1069-A2DD-08002B30309D} = CLSID_ControlPanel
{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0} = CLSID_ControlPanelRecent
{ED7BA470-8E54-465E-825C-99712043E01C} = CLSID_ControlPanelTasks
{26EE0668-A00A-44D7-9371-BEB064C98683} = CLSID_ControlPanelCategory

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

According to the Registry, {26EE0668-A00A-44D7-9371-BEB064C98683} is for the "Control Panel", whereas {21EC2020-3AEA-1069-A2DD-08002B30309D} is for "All Control Panel Items".

See the HKEY_CLASSES_ROOT\CLSID\{26EE0668-A00A-44D7-9371-BEB064C98683} and HKEY_CLASSES_ROOT\CLSID\{21EC2020-3AEA-1069-A2DD-08002B30309D} keys.

According to Complete List of Windows 10 CLSID Key (GUID) Shortcuts:

Control Panel                           {5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}
Control Panel (All Tasks)               {ED7BA470-8E54-465E-825C-99712043E01C}
Control Panel (always Category view)    {26EE0668-A00A-44D7-9371-BEB064C98683}
Control Panel (always Icons view)       {21EC2020-3AEA-1069-A2DD-08002B30309D}

Same with CLSID Key (GUID) Shortcuts List for Windows 7:

Control Panel                   {5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}
Control Panel (All Tasks)       {ED7BA470-8E54-465E-825C-99712043E01C}
Control Panel (Category view)   {26EE0668-A00A-44D7-9371-BEB064C98683}
Control Panel (Icons view)      {21EC2020-3AEA-1069-A2DD-08002B30309D}

According to the Magic Number Database, these CLSIDs are labeled as follows:

{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0} = CLSID_ControlPanelRecent
{ED7BA470-8E54-465E-825C-99712043E01C} = CLSID_ControlPanelTasks
{26EE0668-A00A-44D7-9371-BEB064C98683} = CLSID_ControlPanelCategory
{21EC2020-3AEA-1069-A2DD-08002B30309D} = CLSID_ControlPanel

So, you are likely going to have to filter on all of them.
0x01AA 29-Jul-20 13:46pm
Haha, nice to see you here and have a 5 :-)
Still using your 'indy components' ;)
MyOldAccount 30-Jul-20 5:47am
5ed, thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100