我正在开发一个应用程序,因为我需要显示" New"的子菜单。上下文菜单。即,当我们右键单击桌面时,我们获得新的上下文菜单项,点击新的,我们得到"文件夹","快捷方式","文本文档"等等。
我的问题是 -
答案 0 :(得分:5)
新和发送到菜单项是实现IContextMenu(2,3)
接口的简单shell扩展。 新外壳扩展程序的CLSID为{D969A300-E7FF-11d0-A93B-00A0C90F2719}
,发送至外壳扩展程序的CLSID为{7BA4C740-9E81-11CF-99D3-00AA004AE837}
。因此,您需要为IContextMenu
接口实现主机。
创建一个COM对象
查询IContextMenu
和IShellExtInit
致电IShellExtInit.Initialize()
创建临时菜单
致电IContextMenu.QueryContextMenu()
在临时菜单中,您将拥有所有可用的命令。
IContextMenu.InvokeCommand()
。您可以在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