How would one go about adding a submenu item to the windows explorer context menu (like for example 7-Zip does) for a Java application?
如何为Java应用程序添加子菜单项到Windows资源管理器上下文菜单(例如7-Zip)?
2 个解决方案
#1
16
I am aware of two ways to do it. The fancy way is to write a windows shell extension, which is how powerarchiver, winzip etc do it I believe (this involves running code to determine what the context menu items will be dependent on the file chosen).
我知道有两种方法可以做到这一点。花哨的方式是编写一个windows shell扩展,这就是powerarchiver,winzip等我认为这样做(这涉及运行代码来确定上下文菜单项将取决于所选择的文件)。
The simple way, for simple functionality, is you can add an entry in the registry :
简单的方法,对于简单的功能,您可以在注册表中添加一个条目:
HKEY_CLASSES_ROOT\<file type>\shell\<display text>\command
Where <file type>
is the files that this context menu should apply to i.e. *, .mdb, .doc
其中
and
<display text>
what you want to show in the context menu.
<显示文本> 您要在上下文菜单中显示的内容。
Then add the default string as a path to the application you want to launch from the context menu, and you can use %1 to refer to the currently selected file i.e. for MS Access I use :
然后将默认字符串添加为要从上下文菜单启动的应用程序的路径,并且可以使用%1来引用当前选定的文件,即对于我使用的MS Access:
HKEY_CLASSES_ROOT\*\shell\MS Access 2000\command
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "%1"
This then adds a context menu item for any file I select (hence the *), which allows me to launch it in MS Access 2000.
然后,为我选择的任何文件(因此*)添加上下文菜单项,这允许我在MS Access 2000中启动它。
Of course, always back up your registry before hacking it.
当然,在黑客攻击之前总是备份你的注册表。
Your program could do this during install, or on first run.
您的程序可以在安装期间或首次运行时执行此操作。
#2
4
You could also package the java program in an installer like NSIS and you could use NSIS script to generate explorer context menu
您也可以在NSIS等安装程序中打包java程序,并且可以使用NSIS脚本生成资源管理器上下文菜单
#1
16
I am aware of two ways to do it. The fancy way is to write a windows shell extension, which is how powerarchiver, winzip etc do it I believe (this involves running code to determine what the context menu items will be dependent on the file chosen).
我知道有两种方法可以做到这一点。花哨的方式是编写一个windows shell扩展,这就是powerarchiver,winzip等我认为这样做(这涉及运行代码来确定上下文菜单项将取决于所选择的文件)。
The simple way, for simple functionality, is you can add an entry in the registry :
简单的方法,对于简单的功能,您可以在注册表中添加一个条目:
HKEY_CLASSES_ROOT\<file type>\shell\<display text>\command
Where <file type>
is the files that this context menu should apply to i.e. *, .mdb, .doc
其中
and
<display text>
what you want to show in the context menu.
<显示文本> 您要在上下文菜单中显示的内容。
Then add the default string as a path to the application you want to launch from the context menu, and you can use %1 to refer to the currently selected file i.e. for MS Access I use :
然后将默认字符串添加为要从上下文菜单启动的应用程序的路径,并且可以使用%1来引用当前选定的文件,即对于我使用的MS Access:
HKEY_CLASSES_ROOT\*\shell\MS Access 2000\command
"C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "%1"
This then adds a context menu item for any file I select (hence the *), which allows me to launch it in MS Access 2000.
然后,为我选择的任何文件(因此*)添加上下文菜单项,这允许我在MS Access 2000中启动它。
Of course, always back up your registry before hacking it.
当然,在黑客攻击之前总是备份你的注册表。
Your program could do this during install, or on first run.
您的程序可以在安装期间或首次运行时执行此操作。
#2
4
You could also package the java program in an installer like NSIS and you could use NSIS script to generate explorer context menu
您也可以在NSIS等安装程序中打包java程序,并且可以使用NSIS脚本生成资源管理器上下文菜单