简体   繁体   English

C#将上下文菜单项添加到Windows资源管理器中的所有文件类型

[英]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: 是的, *类:

  1. Create the key: 创建密钥:

    HKEY_CLASSES_ROOT\\*\\shell\\Open with MyThing

  2. Create the sub key: 创建子项:

    HKEY_CLASSES_ROOT\\*\\shell\\Open with MyThing\\command

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

  4. 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将提取相应的图标并显示它。


Example

CAP1

For: 对于:

CAP2


.Reg .REG

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.

相关问题 使用C#为所有桌面快捷方式创建自定义右键单击上下文菜单项(Windows资源管理器) - Create custom right-click context menu item with C# for all desktop shortcuts (windows explorer) 将上下文菜单项添加到Windows资源管理器 - Adding a context menu item to windows explorer C#和Windows资源管理器上下文菜单? - C# And windows explorer context menu? Windows资源管理器的C#和上下文菜单 - C# and context menu of windows explorer 在 UWP 中的 Windows Explorer 的文件上下文中添加上下文菜单项 - Add context menu item to Windows Explorer's File context in UWP c#从上下文菜单Windows资源管理器中的选定文件/文件夹中检索文件/文件夹路径 - c# retrieve file/folder path from selected file/folder in Context Menu Windows Explorer 从 Windows 资源管理器“打开方式”上下文菜单获取文件 C# Wpf - Get file from Windows Explorer "open with" Context Menu C# Wpf Windows资源管理器上下文菜单上的InfoTip - InfoTip on Windows explorer context menu item 将程序添加到Windows资源管理器上下文菜单 - Adding program to the windows explorer context menu 将Windows Phone上下文菜单的Silverlight工具箱添加到C#中的listboxitem - Adding a silverlight toolkit for windows phone context menu to a listboxitem in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM