首页 > 应用开发 > IT综合 > C#将自己的程序添加到右键菜单
命名空间:
using Microsoft.Win32;
右键菜单的注册表项在HKEY_CLASSES_ROOT*shell下
关键代码:
RegistryKey reg;
reg = Registry.ClassesRoot;
reg=reg.CreateSubKey(@"*shellmyApp");
//创建新项myApp
reg.SetValue("","程序名称");
//设置项值
reg = Registry.ClassesRoot;
reg.CreateSubKey(@"*shellmyAppcommand");
//创建新项command
reg.SetValue("",Application.ExecutablePath+" %1");
//设置command的值
reg.Close();
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9437124/viewspace-1018102/ ,如需转载,请注明出处,否则将追究法律责任。