C# 设置程序随机启动

来源:互联网 发布:数据分析找规律问题 编辑:程序博客网 时间:2024/06/05 15:14
if (cbStartWithWindow.Checked) { MessageBox.Show("设置开机自启动,需要修改注册表", "提示"); 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 //取消开机自启动 { MessageBox.Show("取消开机自启动,需要修改注册表", "提示"); 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(); }
0 0
原创粉丝点击