I am working on an application in that I need to display the sub menu of "New" context menu. i.e. when we right click on the desktop, we get new context menu item, on clicking on new, we get "Folder", "shortcut", "Text Document" and etc.
My questions are-
The New and Send To menu items are simple shell extensions which implement the IContextMenu(2,3) interfaces. The CLSID of the New shell extension is {D969A300-E7FF-11d0-A93B-00A0C90F2719}, and the CLSID of the Send To shell extension is {7BA4C740-9E81-11CF-99D3-00AA004AE837}. So you need to implement the host for IContextMenu interface.
Create one of the COM objects
Query it for IContextMenu and IShellExtInit
Call IShellExtInit.Initialize()
Create a temp menu
Call IContextMenu.QueryContextMenu()
In the temp menu, you will have all of the available commands.
IContextMenu.InvokeCommand().A lot of details you can find in The Old New Thing blog:
How to host an IContextMenu, part 1 - Initial foray
How to host an IContextMenu, part 2 - Displaying the context menu
How to host an IContextMenu, part 3 - Invocation location
How to host an IContextMenu, part 4 - Key context
How to host an IContextMenu, part 5 - Handling menu messages
How to host an IContextMenu, part 6 - Displaying menu help
How to host an IContextMenu, part 7 - Invoking the default verb
How to host an IContextMenu, part 8 - Optimizing for the default command
How to host an IContextMenu, part 9 - Adding custom commands
How to host an IContextMenu, part 10 - Composite extensions - groundwork
How to host an IContextMenu, part 11 - Composite extensions - composition
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With