如何获取ShellNew子菜单项

时间:2014-04-14 04:47:39

标签: windows winapi visual-c++

我正在开发一个应用程序,因为我需要显示" New"的子菜单。上下文菜单。即,当我们右键单击桌面时,我们获得新的上下文菜单项,点击新的,我们得到"文件夹","快捷方式","文本文档"等等。

我的问题是 -

  1. 是否有任何API可以获取新列表的子菜单?
  2. 还有任何API可以获得"发送到"?
  3. 的子菜单

1 个答案:

答案 0 :(得分:5)

发送到菜单项是实现IContextMenu(2,3)接口的简单shell扩展。 外壳扩展程序的CLSID为{D969A300-E7FF-11d0-A93B-00A0C90F2719}发送至外壳扩展程序的CLSID为{7BA4C740-9E81-11CF-99D3-00AA004AE837}。因此,您需要为IContextMenu接口实现主机。

  1. 创建一个COM对象

  2. 查询IContextMenuIShellExtInit

  3. 致电IShellExtInit.Initialize()

  4. 创建临时菜单

  5. 致电IContextMenu.QueryContextMenu()

  6. 在临时菜单中,您将拥有所有可用的命令。

    1. 运行命令调用IContextMenu.InvokeCommand()
    2. 您可以在Old New Thing博客中找到很多详细信息:

      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