Windows 11 context menu

Brass Contributor

I want to create a Windows 11 context menu for my Win32 app, but I don't want to write the dll that uses IExplorerCommand . Is it possible to add a context menu item with an icon using a sparse package without having a dll with IExplorerCommand? I would like to achive something similar like PowerRename uses from PowerToys, but it uses a dll for the context menu.

5 Replies

@Edijs_Perkums_MasterPackager 

Yes you can add context menus by using MSIX Sparse Packages. First, you need to set your MSIX to allow external content to reference content outside its package, in a specific location on disk. Next, the app must point to your Win32 executable and lastly enable the Unvirtualized Resources capability. Once you have done all that, install the sparse package from your MSI package and you should by on your way. A more in-depth article on this here.

 

PS: I work for the Advanced Installer team.

@alexmarin89 Can you provide a specific example of which xml elements need to be used to get a context menu item with an icon?

@Edijs_Perkums_MasterPackagerPretty much any context-menu entry for the Windows Shell is stored in the registry, which you can access using console APIs, Win32 API, or console applications ( some could require a standalone UWP app, although you could also use WinUI 2/3, or another built-in API. )

 

"Windows Command-Line: Introducing the Windows Pseudo Console (ConPTY)" -> https://devblogs.microsoft.com/commandline/windows-command-line-introducing-the-windows-pseudo-conso...

 

"Find the Application User Model ID of an installed app" -> https://learn.microsoft.com/en-us/windows/configuration/find-the-application-user-model-id-of-an-ins...

 

"Application User Model IDs (AppUserModelIDs)" -> https://learn.microsoft.com/en-us/windows/win32/shell/appids#registering-an-application-as-a-host-pr...

 

"Verbs and File Associations" -> https://learn.microsoft.com/en-us/windows/win32/shell/fa-verbs

 

"Extending the Context Menu and Share Dialog in Windows 11" -> https://blogs.windows.com/windowsdeveloper/2021/07/19/extending-the-context-menu-and-share-dialog-in...

 

"Application Registration" -> https://learn.microsoft.com/en-us/windows/win32/shell/app-registration

 

"Shell (COM)" -> https://learn.microsoft.com/en-us/windows/win32/com/shell

 

"WinUI" -> https://microsoft.github.io/microsoft-ui-xaml/

 

"Registry Reference" -> https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-reference

 

"reg commands" -> https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg

 

"regini" -> https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/regini

 

"about_Registry_Provider (PowerShell)" -> https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_registry_p...

 

"Windows registry information for advanced users" -> https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/windows-registry-advanced-...

 

"Registry Hives" -> https://learn.microsoft.com/en-us/windows/win32/sysinfo/registry-hives

 

@Edijs_Perkums_MasterPackagerThe easiest example I can give if you want to use other tools such as VS or MSIX Packaging tool is to check this example here.

I have seen that example and that is what I'm trying to avoid. I don't want to write a dll to have a context menu, for win32 apps I can create a registry HKEY_CLASSES_ROOT\.myextension and add the progid in the default value and add the verb under here - HKEY_CLASSES_ROOT\MyProgid\shell\MyVerb. And that is all I need to get a context menu item with an Icon. I am wondering if I can do the same with a sparse package so this context menu is shown on the new Windows 11 context menu, not the old one by clicking show more options. I hope this makes it more clear what I'm trying to achieve.