操纵Windows资源管理器右键菜单 [英] manipulate Windows explorer context menu

查看:216
本文介绍了操纵Windows资源管理器右键菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在写的应用程序使用WPF中框架3.5 SP1,我需要我的功能扩展到Windows资源管理器右键菜单,怎么样的Winzip或WinRAR或者其他任何人没有当用户右键点击一个文件或文件夹。

我做了很多的研究,有的说使用注册表了以后,我试过了,是相当不灵活。因为我需要的子菜单中的我的上下文菜单,也图标。

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

shell编程需要COM编程的知识,这需要时间去学习。

对于所有的文章中,我发现了有关修改Windows资源管理器右键菜单,他们大多是在2003年出版的一年,2005年等,这是5年前,我的意思是,5年的发展后,有没有什么新的技术,可以使这有可能在目前的.NET Framework 3.5一样SP1或4.0使用C#?

感谢。

解决方案

对每个文件夹添加应用右键

下面是如何添加任何应用程序上下文菜单,当你右击任何文件夹。这样,您就不必总是去到开始菜单。当你右击任何文件夹,您可以访问该应用程序,就像使用发送至。

  
      
  1. 开启注册表编辑器
  2.   
  3. 转到HKEY_CLASSES_ROOT \文件夹\壳
  4.   
  5. 添加一个新的关键的壳牌键,将其命名为任何你喜欢的。
  6.   
  7. 给它会出现当你右键点击一个文件夹的默认值,   即则newkey(使用&放大器;无   报价,任何字符前面,   它可以让你使用键盘)

  8.   
  9. 点击键HKEY_CLASSES_ROOT \文件夹\壳\则newkey

  10.   
  11. 添加一个名为命令新的密钥
  12.   
  13. 设置应用程序的(默认)值要运行
  14.   
  15. 例如:C:\ Program Files文件\的Internet Explorer \ IEXPLORE.EXE   (包括完整路径和参数   如果需要的话)
  16.   

写作code为你....

编辑:

code在C#(对于文件夹)

 私人无效的button1_Click(对象发件人,EventArgs的)
    {
        Microsoft.Win32.RegistryKey contextMenuKey = Registry.ClassesRoot.CreateSubKey(@文件夹\壳\ MYNAME \命令);
        // MYNAME的名称,显示
        contextMenuKey.SetValue(NULL,@C:\ Program Files文件\的Internet Explorer \ IEXPLORE.EXE);
        您的应用程序//空或来设置(默认)值,全路径
    }
 

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.

解决方案

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
    }

这篇关于操纵Windows资源管理器右键菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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