C#将上下文菜单项添加到Windows资源管理器中的所有文件类型 [英] C# adding context menu item to windows explorer for all file types

查看:73
本文介绍了C#将上下文菜单项添加到Windows资源管理器中的所有文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在编写一个应用程序,需要修改Windows资源管理器的上下文菜单,以便可以在应用程序内调用一种方法,以在Windows资源管理器中看到的所有文件/文件夹上使用该方法.

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.

由于关于如何添加特定文件类型的上下文菜单的大量关于stackoverflow的文章(以及教程),我已经知道通常可以通过将应用程序分配给注册表项的正确部分来完成此操作.这些文件类型.

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.

由于我不想将自己仅限于特定的文件类型,所以我的问题是:有什么办法吗?将此新的上下文菜单项分配给所有文件类型(除了遍历每个注册表项之外)以...开始 .并将应用程序分配给他们)?

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

推荐答案

是的, * 类:

  1. 创建密钥:

  1. Create the key:

HKEY_CLASSES_ROOT \ * \ shell \用MyThing打开

创建子项:

HKEY_CLASSES_ROOT \ * \ shell \使用MyThing \ command打开

默认值设置为命令行:

C:\ foo \ myThing.exe%1"

(您还可以在此处添加固定值: C:\ foo \ myThing.exe%1"/ranfromshell )

(You can add fixed values here also: C:\foo\myThing.exe "%1" /ranfromshell)

要设置可选图标,请在以下位置创建字符串 value Icon :

To set an optional icon create the string value Icon in:

HKEY_CLASSES_ROOT \ * \ shell \用MyThing打开

您可以在此处放置图标,dll或exe的路径-Windows将提取相应的图标&显示它.

You can put the path to an icon, dll or exe here - Windows will extract the appropriate icon & display it.


示例

针对:

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

这篇关于C#将上下文菜单项添加到Windows资源管理器中的所有文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆