直接使用下列代码即可,亲测有效。
设置开机启动代码如下:
string path = Application.ExecutablePath;
RegistryKey rk = Registry.CurrentUser;
RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rk2.SetValue("JcShutdown", path);
rk2.Close();
rk.Close();
关闭开机启动代码如下:
string path1 = Application.ExecutablePath;
RegistryKey rk1 = Registry.CurrentUser;
RegistryKey rk21 = rk1.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rk21.DeleteValue("JcShutdown", false);
rk21.Close();
rk1.Close();