`
hulianwang2014
  • 浏览: 690030 次
文章分类
社区版块
存档分类
最新评论
  • bcworld: 排版成这样,一点看的欲望都没有了
    jfinal

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();

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics