描述:
象Flashget那样,可以在HKEY_CURRENT_USER\Software\Microsoft\Internet
Explorer\MenuExt\下添加一项,使得IE右键增加一项,但是我如果想先添加一个子菜单,再添加我的项,怎么实现呢?
解决方案1:
http://www.goupsoft.com/ezsaveflash
这个软件实现了.
http://www.pcmag.com/article2/0,1759,1166596,00.asp
You can choose between two strategies. The first approach is to declare your menu entries in the Registry, under the key HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt. This process is described in the MSDN Library (article Q177241). This was the wrong choice for Web Highlighter for two main reasons: First, these menu items can only point to executables or scripts, making communication with the BHO module very difficult. Second, the menu commands cannot be updated (for example, grayed or checked) to reflect current settings.
The second approach is to implement the IDocHostUIHandler interface in the BHO and use ICustomDoc::SetUIHandler to notify Internet Explorer that the program will display the context menu itself. IDocHostUIHandler::ShowContextMenu is the method used to modify the way the standard context menu is displayed. Unfortunately, Internet Explorer doesn't let you add your own menu items to the existing menu. Either you let Internet Explorer display its own menu, or you replace it completely. There are no other options!
The solution is awkward, but there was no other choice. Web Highlighter must build a context menu that is a replica of the standard Internet Explorer context menu and then add its own commands to this menu. To do this, Web Highlighter retrieves the IE menu from the resources contained in Shdoclc.dll (this is where the various flavors of the standard context menus reside), selects the relevant menu according to the context, and then adds its own commands. The code of IDocHostUIHandler::ShowContextMenu contains all the details.
Note that when the replacement context menu is activated, the Internet Explorer window procedure recognizes its own menu items when receiving the WM_INITMENUPOPUP message and updates them according to the context (for example, checking an item or graying it). But any command that is not recognized by Internet Explorer is disabled. This is a very strange and unfriendly way of handling extensions to the WebBrowser control.
Again, the workaround is awkward, but there is no other solution: Before calling TrackPopupMenu to display the context menu, Web Highlighter subclasses the Internet Explorer window temporarily and handles the WM_INITMENUPOPUP message in a custom routine, where Web Highlighter updates its own menu items. Immediately after the pop-up menu closes, the original window procedure is restored.
see also
http://blog.csdn.net/jiangsheng/archive/2004/11/07/170742.aspx