使用 Microsoft.Win32.RegistryKey读写注册表

时间:2022-09-05 09:06:10

使用 Microsoft.Win32.RegistryKey读写注册表

//添加当前程序为开机启动项
string path = Application.ExecutablePath;
Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.LocalMachine;
Microsoft.Win32.RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rk2.SetValue("JcShutdown", path);
rk2.Close();
rk.Close();