如何在Windows中制作上下文菜单子菜单?

问题描述:

我一直在编写实用程序,并通过*的Shell键上的Regedit将它们映射到上下文菜单,但是我不知道如何像一些更流行的实用程序一样制作子菜单。

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.

您可以创建通过注册表访问WIN 7的上下文菜单的子菜单,如这里

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).

菜单:

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

命令:

[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"

请小心编辑注册表,其他版本的Windows可能会有所不同。

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