wtuqi
5/12/2020 - 1:40 PM

Regedit注册表

//打开注册表编辑器并定位到指定路径
Microsoft.Win32.RegistryKey Reg;
Reg = Microsoft.Win32.Registry.CurrentUser;//定义主键
Microsoft.Win32.RegistryKey Key;//定义目录位于主键
key = Reg.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Applets\\Regedit", true)//打开注册表路径
key.SetValue("LastKey", "计算机\\HKEY_CURRENT_USER\\Software");//写入值
key.Close();
System.Diagnostics.Process.Start("regedit");//打开编辑器
//程序开机启动
Microsoft.Win32.RegistryKey Reg;
Reg = Microsoft.Win32.Registry.CurrentUser;
Microsoft.Win32.RegistryKey key1 = Reg.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true);
key.SetValue("WindowsCtrl", Application.ExecutablePath);//写入注册表
key.Close();