Q: Desktop5 vs Desktop7 Context Menus

MVP

The Desktop5 style of defining a Context Menu worked for some context menus and not others.  The new desktop9 style of defining a Context Menu is now available (but not on Windows 10).  So how can we know which style to use when repackaging an application (in absence of testing to see what works first)?

 

I am guessing that it might be the following, and I am looking for confirmation so that third party tooling can "do the right thing" when repackaging existing apps.

 

Context Menus may be implemented in two different ways:

  • The older IContextMenuHandler interface which registers using the GUID {31508CC7-9BC7-59B5-9D0F-7B1C7F144182} under the ShellEx key.
  • The newer IContentMenu interface which registers using the string ContextMenuHandlers under the ShellEx key.

 

My guess is that Desktop7 "Classic" ContextMenu style is used for the IContextMenu and Desktop5 is used for the IContextMenuHandler style.

 

Can you confirm this?

3 Replies

@TIMOTHY MANGAN thank you for your question. Someone will be available to answer this question in the new year as soon as possible.

Hi @TIMOTHY MANGAN,  

Desktop4, and 5 should be all that is needed to get a context menu item registered on both Win 10 and 11. The underlying implementation of the context menu handler will be IExplorerCommand, not IContextMenuHandler. Below is a snippet of what the appxmanifest may look like.

It works for both fully packaged and Sparse Manifested apps.

AppModelSamples/Samples/SparsePackages at master · microsoft/AppModelSamples · GitHub

 

      <Extensions>

        <desktop4:Extension Category="windows.fileExplorerContextMenus">

          <desktop4:FileExplorerContextMenus>

            <desktop5:ItemType Type="Directory\Background">

              <desktop5:Verb Id="Command1" Clsid="6e3f39d5-bdfa-4024-ab7e-4c7ae044670b" />

            </desktop5:ItemType>

            <desktop5:ItemType Type="Directory">

              <desktop5:Verb Id="Command4" Clsid="3083B828-F5DC-4817-94B8-2BAC6A6133C6" />

            </desktop5:ItemType>

            <desktop5:ItemType Type=".txt">

              <desktop5:Verb Id="Command1" Clsid="6e3f39d5-bdfa-4024-ab7e-4c7ae044670b" />

              <desktop5:Verb Id="Command2" Clsid="8B9B3EB1-4D5E-4B36-818C-A98FE817A99F" />

              <desktop5:Verb Id="Command3" Clsid="0326A64C-73B7-41A6-B555-1958325ECE4D" />

              <desktop5:Verb Id="Command5" Clsid="1F0A105D-69BC-469D-9114-BC64317DC1A7" />

            </desktop5:ItemType>

          </desktop4:FileExplorerContextMenus>

        </desktop4:Extension>

        <com:Extension Category="windows.comServer">

          <com:ComServer>

            <com:SurrogateServer  DisplayName="Context menu verb handler">

              <com:Class Id="6e3f39d5-bdfa-4024-ab7e-4c7ae044670b" Path="ContextMenuSample\ContextMenuSample.dll" ThreadingModel="STA"/>

            </com:SurrogateServer>

            <com:SurrogateServer  DisplayName="Context menu verb handler">

              <com:Class Id="8B9B3EB1-4D5E-4B36-818C-A98FE817A99F" Path="ContextMenuSample\ContextMenuSample.dll" ThreadingModel="STA"/>

            </com:SurrogateServer>

            <com:SurrogateServer  DisplayName="Context menu verb handler">

              <com:Class Id="0326A64C-73B7-41A6-B555-1958325ECE4D" Path="ContextMenuSample\ContextMenuSample.dll" ThreadingModel="STA"/>

            </com:SurrogateServer>

            <com:SurrogateServer  DisplayName="Context menu verb handler">

              <com:Class Id="3083B828-F5DC-4817-94B8-2BAC6A6133C6" Path="ContextMenuSample\ContextMenuSample.dll" ThreadingModel="STA"/>

            </com:SurrogateServer>

            <com:SurrogateServer  DisplayName="Context menu verb handler">

              <com:Class Id="1F0A105D-69BC-469D-9114-BC64317DC1A7" Path="ContextMenuSample\ContextMenuSample.dll" ThreadingModel="STA"/>

            </com:SurrogateServer>

          </com:ComServer>

        </com:Extension>

 

I'm implementing a context menu handler using a single class (handling '*' and 'Directory' with the same verb and DLL).
I have two issues:
1) File Explorer is creating a root menu item with two identical menu items (my root node).
2) Some menu items require a submenu, but File Explorer doesn't open it.
The same context menu item appears under "Show More Options" and, despite duplicating my root node, it correctly shows the submenus and executes the Invoke method after clicking it.
How can I avoid showing that auto-generated root node?
Thanks,
David Izada Rodriguez