[英]C# adding context menu item to windows explorer for all file types
I'm currently writing an application where I need to modify the context menu of windows explorer so that I can call a method within the application to be used on all files/folders that are seen in windows explorer. 我目前正在编写一个应用程序,需要修改Windows资源管理器的上下文菜单,以便可以在应用程序内调用一种方法,以在Windows资源管理器中看到的所有文件/文件夹上使用该方法。
As there are already quite a few posts on stackoverflow (and also tutorials) on how to add the context menu for specific file types I know already that that is done usually by assigning the application to the right parts of the registry entry for those file types. 因为关于如何为特定文件类型添加上下文菜单的大量关于stackoverflow的文章(以及教程),我已经知道通常是通过将应用程序分配给这些文件类型的注册表项的正确部分来完成的。
As I don't want to limit myself to only specific filetypes my question is: IS there any way to assign this new context menu item to ALL filetypes (aside from going through each registry entry beginning with . and assigning the application to them there)? 因为我不想将自己仅限于特定的文件类型,所以我的问题是:是否有任何方法可以将此新的上下文菜单项分配给所有文件类型(除了通过。开头的每个注册表项并在那里将应用程序分配给它们) ?
Yes, the *
class: 是的, *
类:
Create the key: 创建密钥:
HKEY_CLASSES_ROOT\\*\\shell\\Open with MyThing
Create the sub key: 创建子项:
HKEY_CLASSES_ROOT\\*\\shell\\Open with MyThing\\command
Set the default value to your command line: 将默认值设置为您的命令行:
C:\\foo\\myThing.exe "%1"
(You can add fixed values here also: C:\\foo\\myThing.exe "%1" /ranfromshell
) (您还可以在此处添加固定值: C:\\foo\\myThing.exe "%1" /ranfromshell
)
To set an optional icon create the string value Icon
in: 要设置可选图标,请在以下位置创建字符串值 Icon
:
HKEY_CLASSES_ROOT\\*\\shell\\Open with MyThing
You can put the path to an icon, dll or exe here - Windows will extract the appropriate icon & display it. 您可以在此处放置图标,dll或exe的路径-Windows将提取相应的图标并显示它。
For: 对于:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Open with MyThing]
"Icon"="C:\\foo\\myThing.exe"
[HKEY_CLASSES_ROOT\*\shell\Open with MyThing\command]
@="C:\\foo\\myThing.exe \"%1\""
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.