try
{
RegistryKey hklm = Registry.LocalMachine;
RegistryKey run = hklm.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
if (checkBox1.Checked == true)
{
  run.SetValue("thisApplication.exe", System.Windows.Forms.Application.ExecutablePath);
hklm.Close();
}
MessageBox.Show("设置开机成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
}
catch
{ }

 

以上代码是从别人的项目里面扣出来,不过大家可以自己重载下,写成一个通用的方法。

相关文章:

  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2021-09-09
  • 2021-11-23
  • 2022-12-23
  • 2021-12-04
  • 2021-10-25
  • 2022-12-23
相关资源
相似解决方案