//添加启动项
/// <summary>
/// 开机随系统启动
/// </summary>
public void start_with_windows()
{
if (start_with_win1.Checked)
{
start_with_win1.Checked = false;
start_with_win2.Checked = false;
RegistryKey hklm = Registry.LocalMachine;
RegistryKey run = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
if (run.GetValue("校园网登陆器")!= null)
{
run.DeleteValue("校园网登陆器");
}
run.Close();
hklm.Close();
}
else
{
RegistryKey hklm = Registry.LocalMachine;
RegistryKey run = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
if (run.GetValue("校园网登陆器") == null)
{
start_with_win1.Checked = true;
start_with_win2.Checked = true;
string exeFileName = Application.ExecutablePath;//含可执行文件名
run.SetValue("校园网登陆器", exeFileName);
}
else
{
run.DeleteValue("校园网登陆器");
start_with_win1.Checked = true;
start_with_win2.Checked = true;
string exeFileName = Application.ExecutablePath;//含可执行文件名
run.SetValue("校园网登陆器", exeFileName);
}
run.Close();
hklm.Close();
}
}
/// <summary>
/// 开机随系统启动
/// </summary>
public void start_with_windows()
{
if (start_with_win1.Checked)
{
start_with_win1.Checked = false;
start_with_win2.Checked = false;
RegistryKey hklm = Registry.LocalMachine;
RegistryKey run = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
if (run.GetValue("校园网登陆器")!= null)
{
run.DeleteValue("校园网登陆器");
}
run.Close();
hklm.Close();
}
else
{
RegistryKey hklm = Registry.LocalMachine;
RegistryKey run = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
if (run.GetValue("校园网登陆器") == null)
{
start_with_win1.Checked = true;
start_with_win2.Checked = true;
string exeFileName = Application.ExecutablePath;//含可执行文件名
run.SetValue("校园网登陆器", exeFileName);
}
else
{
run.DeleteValue("校园网登陆器");
start_with_win1.Checked = true;
start_with_win2.Checked = true;
string exeFileName = Application.ExecutablePath;//含可执行文件名
run.SetValue("校园网登陆器", exeFileName);
}
run.Close();
hklm.Close();
}
}