string startpath = Application.ExecutablePath;
RegistryKey loca = Registry.LocalMachine;
RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
if (run.GetValue("BootForm") == null)
{
try
{
//SetValue:存储值的名称
run.SetValue("BootForm", startpath);//BootForm软件名称
loca.Close();
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
C#开机自动启动软件
最新推荐文章于 2023-11-03 14:22:03 发布