I'm implementing a Basic Folder Object for a namespace extension composed by folders and subfolders (the junction point is a filesystem folder, which is empty). I've implemented IShellFolder
, and support returning IContextMenu
in ShellFolderImpl::GetUIObjectOf
.
Suppose that I have the following folders (where A and A\B are "virtual" folders fabricated by IShellFolder::EnumObjects
)
C:\test.{74660590-4BEF-4BF4-9C85-5FAE0E084926}
C:\test.{74660590-4BEF-4BF4-9C85-5FAE0E084926}\A
C:\test.{74660590-4BEF-4BF4-9C85-5FAE0E084926}\A\B
I'm able to open C:\test.{74660590-4BEF-4BF4-9C85-5FAE0E084926}
, and it lists the folder A. When I double-click (or select Open from context menu) on folder A, that folder is opened and subfolder B is listed in the view.
Problem: that only works for folders directly under C:\test.{74660590-4BEF-4BF4-9C85-5FAE0E084926}
. The context menu is not displayed for subfolder B (and GetUIObjectOf
is never called, even though IShellFolder:Initialize
is called with the right PIDL).
In the relevant part of IContextMenu::InvokeCommand
, I open the subfolder by doing
SHELLEXECUTEINFO sei = { 0 };
sei.cbSize = sizeof(sei);
sei.fMask = SEE_MASK_IDLIST | SEE_MASK_CLASSNAME;
sei.lpIDList = pidl; // the fully qualified PIDL
sei.lpClass = TEXT("folder");
sei.hwnd = pcmi->hwnd;
sei.nShow = pcmi->nShow;
sei.lpVerb = cmd.verb.w_str();
BOOL bRes = ::ShellExecuteEx(&sei);
DeletePidl(pidl);
return bRes?S_OK:HR(HRESULT_FROM_WIN32(GetLastError()));