Forum Discussion
Dec 01, 2021
Q: Desktop5 vs Desktop7 Context Menus
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...
harshada2019
Microsoft
Jan 03, 2022Hi 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>
DavidIzadaR
Oct 10, 2022Copper Contributor
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
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