Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get ShellNew sub menu items

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-

  1. Is there any API to Get List to sub menu of new?
  2. Also is there any API to get sub menu of "Send To"?
like image 476
Umesha MS Avatar asked Jul 06 '26 01:07

Umesha MS


1 Answers

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.

  1. Create one of the COM objects

  2. Query it for IContextMenu and IShellExtInit

  3. Call IShellExtInit.Initialize()

  4. Create a temp menu

  5. Call IContextMenu.QueryContextMenu()

In the temp menu, you will have all of the available commands.

  1. To run a command call 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

like image 66
Denis Anisimov Avatar answered Jul 08 '26 14:07

Denis Anisimov