【发布时间】:2011-12-09 17:13:28
【问题描述】:
我一直在编写实用程序并通过 * 的 Shell 键上的 Regedit 将它们映射到上下文菜单,但我不知道如何像一些更流行的实用程序那样制作子菜单。
例如,如果我有三个脚本将文件移动和重命名到三个不同的文件夹,那么现在我有三个不同的上下文菜单条目。我希望有一个名为“移动和重命名...”的扩展至这三个。
【问题讨论】:
标签: windows contextmenu
我一直在编写实用程序并通过 * 的 Shell 键上的 Regedit 将它们映射到上下文菜单,但我不知道如何像一些更流行的实用程序那样制作子菜单。
例如,如果我有三个脚本将文件移动和重命名到三个不同的文件夹,那么现在我有三个不同的上下文菜单条目。我希望有一个名为“移动和重命名...”的扩展至这三个。
【问题讨论】:
标签: windows contextmenu
您可以通过注册表创建上下文菜单的子菜单,WIN 7 见here
备份建议先备份您的注册表!
此示例将带有单个命令的子菜单放入任何文件(不是文件夹或桌面)的右键单击上下文中。
菜单:
[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"
请谨慎编辑您的注册表,其他版本的窗口可能会有所不同。
【讨论】:
您可以使用子命令指定组/菜单名称并指定项目,例如 - 为 EXE 文件制作上下文菜单
group name: "InstallShield debug"
group subcommands:InstDbg1;InstDbg2;InstDbg3;InstDbg4;InstDbg5;InstDbg6;InstDbg7
group item1: name: "debug installer /d" ; key InstDbg1
group item2: name: "debug installer /d /v..." ; key InstDbg2
etc
用于此的 reg 文件是
Windows Registry Editor Version 5.00
;cascading context menu - use empty lines between registry items
;separator before: "CommandFlags"=dword:00000020
;SubCommands contains keys to be found in the registry - should match
KEY_CLASSES_ROOT\exefile\shell\InstallShield cascade menu]
"MUIVerb"="InstallShield debug"
"Icon"="C:\\Program Files (x86)\\InstallShield\\2020\\System\\isdev.exe"
"SubCommands"="InstDbg1;InstDbg2;InstDbg3;InstDbg4;InstDbg5;InstDbg6;InstDbg7"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg1]
@=""
"MUIVerb"="debug installer /d"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg1\command]
@="\"%1\" /d"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg2]
@=""
"MUIVerb"="debug installer /d /v TEST_STATUS=Good"
"CommandFlags"=dword:00000020
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg2\command]
@="\"%1\" /d /v\"TEST_STATUS=Good\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg3]
@=""
"MUIVerb"="debug installer /d /v TEST_STATUS=Undetermined"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg3\command]
@="\"%1\" /d /v\"TEST_STATUS=Undetermined\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg4]
@=""
"MUIVerb"="debug installer /d /v TEST_STATUS=Unauthorized"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg4\command]
@="\"%1\" /d /v\"TEST_STATUS=Unauthorized\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg5]
@=""
"MUIVerb"="run installer /v TEST_STATUS=Good"
"CommandFlags"=dword:00000020
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg5\command]
@="\"%1\" /v\"TEST_STATUS=Good\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg6]
@=""
"MUIVerb"="run installer /v TEST_STATUS=Undetermined"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg6\command]
@="\"%1\" /v\"TEST_STATUS=Undetermined\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg7]
@=""
"MUIVerb"="run installer /v TEST_STATUS=Unauthorized"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\InstDbg7\command]
@="\"%1\" /v\"TEST_STATUS=Unauthorized\""
【讨论】:
你必须写一个自定义的Context Menu Handler。
【讨论】:
您尚未指定您使用的语言。无论如何,您需要做的是编写一个 Shell 扩展。有一个指南,here。
正如 David 指出的那样,在 C# 中不可能做到这一点This blog post 解释它。
【讨论】: