Shell Context Menu Support in MSIX Packaging
What is Context Menu?
The Context Menu is undeniably one of the most useful shell extensions in Windows. This menu appears when you right-click on an object, like a file, folder, or icon, in Windows Explorer or File Explorer.
Context Menu offers a quick and easy way to access various actions and options for the selected object.
Available context menu options vary based on the object's type and the software installed on your system. Beyond the standard options Windows provides, some applications add their own to enhance functionality.In this article, we'll delve into the nuances of the Context Menu, particularly focusing on its integration and support within MSIX packaging.
Let’s explore how this functionality is implemented, using the popular file archiver, 7Zip, as a practical example.
MSIX Support for Context Menu
Starting with MSIX Packaging Tool version 1.2022.11, legacy ContextMenu interfaces for shell extensions are automatically detected and added into the Appxmanifest file. This applies for both context menu or drag and drop handlers.
The Context Menu requires Windows 11 21H2 and later in order to work as expected.
According to Microsoft documentation, for Windows Shell to recognize and register the extension, the Appxmanifest file must include specific namespaces:
- Windows.comserver extension.
<com:Extension Category="windows.comServer"> <com:ComServer> <com:SurrogateServer DisplayName="<display-name-for-the-com-server>"> <com:Class Id="<GUID-for-the-com-server>" Path="<path-to-the-com-server-or-dll>" ThreadingModel="STA" /> </com:SurrogateServer> </com:ComServer> </com:Extension>
- Desktop9 namespace – here you can have either a FileExplorerClassicContextMenuHandler or a FileExplorerClassicDragDropContextMenuHandler extension.
<desktop9:Extension Category="windows.fileExplorerClassicContextMenuHandler"> <desktop9:FileExplorerClassicContextMenuHandler> <desktop9:ExtensionHandler Type="*" Clsid="<GUID-for-the-com-server>" /> <desktop9:ExtensionHandler Type=".txt" Clsid="<GUID-for-the-com-server>" /> <desktop9:ExtensionHandler Type="Directory" Clsid="<GUID-for-the-com-server>" /> </desktop9:FileExplorerClassicContextMenuHandler> </desktop9:Extension> <desktop9:Extension Category="windows.fileExplorerClassicDragDropContextMenuHandler"> <desktop9:FileExplorerClassicDragDropContextMenuHandler> <desktop9:ExtensionHandler Type="Directory" Clsid="<GUID-for-the-com-server>" /> <desktop9:ExtensionHandler Type="Drive" Clsid="<GUID-for-the-com-server>" /> </desktop9:FileExplorerClassicDragDropContextMenuHandler> </desktop9:Extension>
Additionally, the “MaxVersionTested” should be set to a value greater than “10.0.21300.0”.
<Dependencies> <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.21301.0" /> </Dependencies>
Now that we know what Context Menu is and how it works, let’s give it a try. And what more suitable application we could have other than 7Zip.
Conclusion
In enterprise environments and beyond, the Context Menu is often an essential functionality. MSIX's default support for Shell Context Menu marks a significant advancement in MSIX packaging and deployment.