操作 Windows 资源管理器上下文菜单

发布于 2024-10-13 07:45:24 字数 406 浏览 3 评论 0原文

我目前正在框架 3.5 SP1 中使用 WPF 编写应用程序,我需要将我的功能扩展到 Windows 资源管理器上下文菜单,就像 Winzip 或 Winrar 或其他任何人在用户右键单击文件或文件夹时所做的那样。

我查了很多资料,有人说用Registry,我试过后觉得很不灵活。因为我需要上下文菜单中的子菜单以及图标。

我发现的另一种方法是 shell 编程,它更令人讨厌,但比注册表方法更有潜力。

Shell编程需要COM编程知识,需要时间学习。

对于我发现的所有关于修改Windows资源管理器上下文菜单的文章,它们大多发表于2003年、2005年等,这是5年前的事了,我的意思是,经过5年的发展,有没有任何新技术可以在当前的情况下实现这一点.net 框架,如 3.5 SP1 或 4.0 使用 c#?

谢谢。

I am currently writing application with WPF in framework 3.5 SP1, and I need to extend my functionality to Windows Explorer context menu, like how Winzip or Winrar or anyone else did when user right click on a file or folder.

I did a lot of study, some said use Registry, which after I tried, is quite inflexible. Because I need sub menu in my context menu, and also icons.

Another approach I found, is the shell programming, which is even more nasty, but have much much more potential than the registry method.

Shell programming require COM programming knowledge, which need time to learn.

For all the articles I found about modifying windows explorer context menu, they are mostly published in year 2003, 2005 etc, it's 5 years ago, I mean, after 5 years of development, is there any new technology that can make this possible in current .net framework like 3.5 SP1 or 4.0 using c#?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹿童谣 2024-10-20 07:45:24

要在 Windows 资源管理器上下文菜单中添加附加条目,您需要在 Windows 注册表中的 HKEY_CLASSES_ROOT\Folder\shell 中添加两个子项,

这些项是:

  1. Folder\shell\MyProduct :此项的值将显示为文本新的 Windows 资源管理器上下文菜单项。您还可以通过向键 1 添加值并将其命名为“Icon”,然后将图标的路径设置为值来将图标添加到上下文菜单项。

  2. Folder\shell\MyProduct\command:设置要启动的应用程序的路径。

以下是更多详细信息和示例 C# 代码的链接:
http://newapputil.blogspot。在/2016/12/adding-new-item-to-context-menu-of.html

To make an additional entry in windows explorer context menu You would need to add two sub keys in windows registry at HKEY_CLASSES_ROOT\Folder\shell

These keys are:

  1. Folder\shell\MyProduct : Value of this key will be shown as text in the new windows explorer context menu item. You can also add a icon to the context menu item by adding a value to the key 1 and name it "Icon" then set path to icon as value.

  2. Folder\shell\MyProduct\command: Set the path of application which you want to launch.

Here is the link for more details and sample C# code:
http://newapputil.blogspot.in/2016/12/adding-new-item-to-context-menu-of.html

脸赞 2024-10-20 07:45:24

将应用程序添加到右键单击每个文件夹

下面介绍了如何在右键单击任何文件夹时将任何应用程序添加到上下文菜单。这样您就不必总是转到“开始”菜单。当您右键单击任何文件夹时,您可以访问该应用程序,就像使用“发送到”一样。

  1. 打开注册表编辑器
  2. 转至 HKEY_CLASSES_ROOT\Folder\shell
  3. 向“Shell”键添加一个新键,并将其命名为您喜欢的任何名称。
  4. 为其指定一个默认值,该值将在您右键单击文件夹时显示,
    即 NewKey(使用“&”,不带
    任何字符前面的引号和
    它将允许您使用键盘)

  5. 单击键 HKEY_CLASSES_ROOT\Folder\shell\NewKey

  6. 添加一个名为 Command 的新键
  7. 设置您要运行的应用程序的(默认)值
  8. 例如:c:\program files\internet explorer\iexplore.exe
    (包括完整路径和参数
    如果你需要的话)

为您编写代码...

编辑:

C# 代码(对于文件夹)

 private void button1_Click(object sender, EventArgs e)
    {           
        Microsoft.Win32.RegistryKey contextMenuKey = Registry.ClassesRoot.CreateSubKey(@"Folder\shell\MyName\command"); 
        //MyName is name to display
        contextMenuKey.SetValue(null, @"c:\program files\internet explorer\iexplore.exe");  
        //null or "" to set value in (Default), full path of your application
    }

Adding an Application to the Right Click on Every Folder

Here is how to add any application to the Context Menu when you right click on any Folder. This way you do not have to always go to the Start Menu. When you right click on any folder, you can have access to that application, the same as using Sent To.

  1. Open RegEdit
  2. Go to HKEY_CLASSES_ROOT\Folder\shell
  3. Add a new Key to the "Shell" Key and name it anything you like.
  4. Give it a default value that will appear when you right click a folder,
    i.e. NewKey (use an "&" without the
    quotes, in front of any character and
    it will allow you to use the keyboard)

  5. Click on the Key HKEY_CLASSES_ROOT\Folder\shell\NewKey

  6. Add a New Key named Command
  7. Set the (Default) value of the application you want to run
  8. For example: c:\program files\internet explorer\iexplore.exe
    (Include the full path and parameters
    if you need them)

Writing code for you....

Edit:

code in C# (for folders)

 private void button1_Click(object sender, EventArgs e)
    {           
        Microsoft.Win32.RegistryKey contextMenuKey = Registry.ClassesRoot.CreateSubKey(@"Folder\shell\MyName\command"); 
        //MyName is name to display
        contextMenuKey.SetValue(null, @"c:\program files\internet explorer\iexplore.exe");  
        //null or "" to set value in (Default), full path of your application
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文