Dec 01 2021 03:29 PM - edited Dec 01 2021 03:29 PM
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:
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?
Dec 14 2021 04:20 PM
@TIMOTHY_MANGAN thank you for your question. Someone will be available to answer this question in the new year as soon as possible.
Jan 03 2022 01:37 PM
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>
Oct 10 2022 10:04 AM