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;
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))
{
skip = pdid.clsid == CLSID_ControlPanel;
}
}
if (skip)
continue;
}
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...