#region 开机自启动
private void checkBox开机自启动_CheckedChanged(object sender, EventArgs e)
{
if (checkBox开机自启动.Checked) //设置开机自启动
{
string path = Application.ExecutablePath;
RegistryKey rk = Registry.LocalMachine;
RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rk2.SetValue("JcShutdown", path);
rk2.Close();
rk.Close();
}
else //取消开机自启动
{
string path = Application.ExecutablePath;
RegistryKey rk = Registry.LocalMachine;
RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
rk2.DeleteValue("JcShutdown", false);
rk2.Close();
rk.Close();
}
}
#endregion
c# 开机自启动
最新推荐文章于 2024-01-29 20:26:07 发布