How do you make context menu submenus in Windows?

寵の児 提交于 2020-02-22 04:17:49

问题


I've been writing utilities and mapping them to context menus via the Regedit on the Shell key of *, but I can't figure out how to make submenus like some of the more popular utilities do.

For example, if I have three scripts to move and rename files to three different folders, right now I have three different context menu entries. I'd prefer to have one called "move and rename..." that expands to those three.


回答1:


You can create a submenu to context menus via registry, WIN 7 as seen here

Backup your registry first is recommended!

This example puts a submenu with a single command into the rightclick context on any file (not folders or desktop).

The menu:

[HKEY_CLASSES_ROOT\*\shell\Custom Menu]
"MUIVerb"="Custom Tools"
"SubCommands"="Custom.copytoclip"

The commands:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Custom.copytoclip]
@="copytoclip description here"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Custom.copytoclip\command]
@="cmd /c clip < %1"

Please be careful editing your registry, other versions of windows may work differently.




回答2:


You have to write a custom Context Menu Handler.




回答3:


You haven't specified what language you are using. Anyway, what you need to do is write a Shell Extension. There'a a guide, here.

As David has pointed out, it is not possible to do this in C# This blog post explains it.



来源:https://stackoverflow.com/questions/8449167/how-do-you-make-context-menu-submenus-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!