For a search application, I am currently trying to index a special “Godmode” folder, which Windows includes for its own search capabilities.
Using a large library Vanara.Windows.Shell, I can currently index my desktop, but as soon as I try to index the Godmode folder, the listing gives no elements. I tried to run the IDE as an admin user, but that did not fix it.
Here is the code I'm working with now:
void Main()
{
Shell32.IShellFolder desktopShellFolder;
Shell32.SHGetDesktopFolder(out desktopShellFolder);
Shell32.PIDL ppidl;
Shell32.SFGAO psfgaoOut;
Shell32.SHParseDisplayName("shell:::{ED7BA470-8E54-465E-825C-99712043E01C}", IntPtr.Zero, out ppidl, (Shell32.SFGAO)0, out psfgaoOut);
var godmodeShellFolder = (Shell32.IShellFolder)desktopShellFolder.BindToObject(ppidl, null, new Guid("000214E6-0000-0000-C000-000000000046"));
CollectSearchItems(godmodeShellFolder, ppidl);
}
void CollectSearchItems(Shell32.IShellFolder shellFolder, Shell32.PIDL pidl)
{
var itemEnum = shellFolder.EnumObjects(IntPtr.Zero, Shell32.SHCONTF.SHCONTF_NONFOLDERS | Shell32.SHCONTF.SHCONTF_FOLDERS);
IntPtr itemId;
uint fetched;
while (itemEnum.Next(1, out itemId, out fetched) == HRESULT.S_OK)
{
Shell32.SFGAO sfgao = Shell32.SFGAO.SFGAO_FOLDER | Shell32.SFGAO.SFGAO_STREAM | Shell32.SFGAO.SFGAO_LINK;
shellFolder.GetAttributesOf(1, new IntPtr[] { itemId }, ref sfgao);
if ((sfgao & Shell32.SFGAO.SFGAO_FOLDER) == 0)
{
var childPidl = new Shell32.PIDL(itemId);
var itemName = shellFolder.GetDisplayNameOf(childPidl, Shell32.SHGDNF.SHGDN_INFOLDER | Shell32.SHGDNF.SHGDN_NORMAL);
}
}
}
If I replace
CollectSearchItems(godmodeShellFolder, ppidl);with CollectSearchItems(desktopShellFolder, ppidl);I can successfully list my desktop, so I think I'm pretty close ...
Why does listing the Godmode folder not work and how can I solve this problem?
source