Click here to Skip to main content
15,883,809 members
Please Sign up or sign in to vote.
5.00/5 (1 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.

C++
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;
        LPAFX_SHELLITEMINFO pItem;

        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));
                psf->Release();
                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)
                continue;
            // insert TreeView item, omitted for brevity
        }
        return hr;
}


RELEVANT INFORMATION:

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

QUESTION:

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...
Posted
Comments
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

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.
 
Share this answer
 
Comments
[no name] 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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900