Assuming that Windows 11 will not accept over one submenu
Yes, this is mentioned in MSDN, in one of the topics on IExplorerCommand.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
After reading Microsoft's documentation, Raymond Chen's blog, NanaZip implementation, and TortoiseSVN/TortoiseGit implementations, I created a "modern" shell extension implementing IClassFactory, IExplorerCommand, and IObjectWithSelection.
I also implemented several other interfaces but finally dropped them because they were unused.
When selecting two files, my context menu should appear like this:
It works correctly after selecting both files and clicking Shift-F10 (that is, on the "Show More Options" submenu).
But it cannot render the "using >" submenu on the top-level menu.
I tried the extension on Windows 7, registering the single root command (implementing IExplorerCommand and IObjectWithSelection), and it works as expected.
Assuming that Windows 11 will not accept over one submenu, the only solution is to use a separator and render the submenu items after it.
In my case, it means to declare CompareFilesUsing as a separator, returning empty values for Title and Icon and ECF_ISSEPARATOR for GetFlags.
Of course, that should be only for Windows 11 on the top-level menu (how to know that is the case?).
In my case, after making the necessary changes, I got the following:
There is something wrong here. There is no ">" announcing the submenu; the separator is just a blank line.
Is that correct? If not, what is happening?
How can my instances work under "Show More Options" and not on the top-level menu?
I have extensive logging in my extension, and I noticed that, even when Explorer uses the same DLL and instances, it follows different strategies for discovering the structure of the context menu provided by the extension. I'm attaching both logs for the command "Compare Files".
268352-tlm-comparefiles.txt => executing the command from the top-level Windows 11 menu
268266-smo-comparefiles.txt => executing the command from the "Show more options" submenu.
Analyzing the logs, it is noticeable that on the top-level menu, Explorer requests two instances of the root command.
This is part of my AppXManifest.xml:
<Extensions>
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:SurrogateServer DisplayName="Beyond Compare shell extension">
<com:Class Id="812BC6B5-83CF-4AD9-97C1-6C60C8D025C5" Path="BcShellEx64.dll" ThreadingModel="STA" />
</com:SurrogateServer>
</com:ComServer>
</com:Extension>
<desktop4:Extension Category="windows.fileExplorerContextMenus">
<desktop4:FileExplorerContextMenus>
<desktop5:ItemType Type="*">
<desktop5:Verb Id="AnyFile" Clsid="812BC6B5-83CF-4AD9-97C1-6C60C8D025C5" />
</desktop5:ItemType>
<desktop5:ItemType Type="Directory">
<desktop5:Verb Id="AnyFolder" Clsid="812BC6B5-83CF-4AD9-97C1-6C60C8D025C5" />
</desktop5:ItemType>
</desktop4:FileExplorerContextMenus>
</desktop4:Extension>
</Extensions>
As my extension accepts files and folders, I had to declare my COM server and the extension category (fileExplorerContextMenus) with two verbs.
I don't know if that is why Explorer spawns two instances, but under "Show More Options," Explorer creates only one instance, while the top-level menu creates two (and uses only one).
Assuming that Windows 11 will not accept over one submenu
Yes, this is mentioned in MSDN, in one of the topics on IExplorerCommand.
I want to conclude this thread by informing everyone of my last decision.
Despite the simplicity of IExplorerCommand, if activating the context menu requires awareness about the selection, must work on unsupported devices, or any other not-so-simple scenario, it is better to use IExplorerCommand for the top-level menu and IContextMenu for everything else.
Microsoft's implementation of IContextMenu is too simplistic and covers just a fraction of what was possible with IContextMenu.