Q: Desktop5 vs Desktop7 Context Menus

%3CLINGO-SUB%20id%3D%22lingo-sub-3025157%22%20slang%3D%22en-US%22%3EQ%3A%20Desktop5%20vs%20Desktop7%20Context%20Menus%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3025157%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20Desktop5%20style%20of%20defining%20a%20Context%20Menu%20worked%20for%20some%20context%20menus%20and%20not%20others.%26nbsp%3B%20The%20new%20desktop9%20style%20of%20defining%20a%20Context%20Menu%20is%20now%20available%20(but%20not%20on%20Windows%2010).%26nbsp%3B%20So%20how%20can%20we%20know%20which%20style%20to%20use%20(in%20absence%20of%20testing)%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20am%20guessing%20that%20it%20might%20be%20the%20following%2C%20and%20I%20am%20looking%20for%20confirmation%20so%20that%20third%20party%20tooling%20can%20%22do%20the%20right%20thing%22%20when%20repackaging%20existing%20apps.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EContext%20Menus%20may%20be%20implemented%20in%20two%20different%20ways%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EThe%20older%20IContextMenuHandler%20interface%20which%20registers%20using%20the%20GUID%26nbsp%3B%7B31508CC7-9BC7-59B5-9D0F-7B1C7F144182%7D%20under%20the%20ShellEx%20key.%3C%2FLI%3E%0A%3CLI%3EThe%20newer%20IContentMenu%20interface%20which%20registers%20using%20the%20string%20ContextMenuHandlers%20under%20the%20ShellEx%20key.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMy%20guess%20is%20that%20Desktop7%20%22Classic%22%20ContextMenu%20style%20is%20used%20for%20the%20IContextMenu%20and%20Desktop5%20is%20used%20for%20the%20IContextMenuHandler%20style.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECan%20you%20confirm%20this%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E
MVP

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:

  • The older IContextMenuHandler interface which registers using the GUID {31508CC7-9BC7-59B5-9D0F-7B1C7F144182} under the ShellEx key.
  • The newer IContentMenu interface which registers using the string ContextMenuHandlers under the ShellEx key.

 

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?

2 Replies

@TIMOTHY MANGAN thank you for your question. Someone will be available to answer this question in the new year as soon as possible.

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>