c++windowscontextmenushell-extensionsappxmanifest

Determine ordering of windows shell context menu extension entries


I am trying to implement a shell extension that displays a number of entries in the windows 10/11 context menu. I have based a lot of my solution on this example: https://github.com/microsoft/AppModelSamples/tree/master/Samples/SparsePackages

This means I am using IExplorerCommand to implement the different command handlers : https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-iexplorercommand

Currently, in my AppxManifest.xml file, for the Directory item type, I have something that looks like the following entries:

  <desktop4:FileExplorerContextMenus>
    <desktop5:ItemType Type="Directory">
      <desktop5:Verb Id="FirstIdString" Clsid="MY-CLSID"/>
      <desktop5:Verb Id="SecondIdString" Clsid="MY-CLSID"/>
      <desktop5:Verb Id="ThirdIdString" Clsid="MY-CLSID"/>
      <desktop5:Verb Id="FourthIdString" Clsid="MY-CLSID"/>
    </desktop5:ItemType>

In the actual context menu, the entries show up in a different ordering to what I have declared here. How would I go about manipulating the index/ordering of the context menu entries?


Solution

  • It turns out that the context menu entries are sorted and grouped based on the string value of the Id attribute of the desktop5:Verb nodes. This does not seem to be documented in the schema reference.