C#.NET程序添加到右键菜单的实现代码
发布时间:2016-03-15 编辑:jiaochengji.com
本文介绍C#.net将自己的程序添加到右键菜单中的实现代码,有需要的朋友,可以参考下。
在文件上单击右键,显示效果如下:
实现方法
引入命名空间:
复制代码 代码示例:
using Microsoft.Win32;
说明:右键菜单的注册表项在/HKEY_CLASSES_ROOT/*/shell下
关键代码:
复制代码 代码示例:
RegistryKey reg;
reg = Registry.ClassesRoot;
reg=reg.CreateSubKey(@"*/shell/myApp");
//创建新项myApp
reg.SetValue("","我的程序");
//设置项值
reg = Registry.ClassesRoot;
reg.CreateSubKey(@"*/shell/myApp/command");
//创建新项command
reg.SetValue("",Application.ExecutablePath+" %1");
//设置command的值
reg.Close();
//edit www.jbxue.com
reg = Registry.ClassesRoot;
reg=reg.CreateSubKey(@"*/shell/myApp");
//创建新项myApp
reg.SetValue("","我的程序");
//设置项值
reg = Registry.ClassesRoot;
reg.CreateSubKey(@"*/shell/myApp/command");
//创建新项command
reg.SetValue("",Application.ExecutablePath+" %1");
//设置command的值
reg.Close();
//edit www.jbxue.com
您可能感兴趣的文章:
C#.NET程序添加到右键菜单的实现代码
C#自定义控件添加右键菜单的实现代码
C#添加鼠标右键菜单的方法介绍
C# winform treeview添加右键菜单并选中节点的方法
ASP.NET控件利用Control.ContextMenu加入快捷菜单
c#.net 匿名函数进行EventHandler参数传递的问题
为jQuery.Treeview添加右键菜单的实现代码
c# TreeView添加右键快键菜单的二个方法
C#创建右键菜单方法与示例
C#下实现动态系统托盘图标
[关闭]