日期:2014-05-18 浏览次数:21296 次
//打开开机启动
private void SetAutoStart()
{
string strPath = Application.ExecutablePath;
RegistryKey loca = Registry.LocalMachine;
try
{
RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
if (run.GetValue("裂帛客服工具") == null)
{
run.SetValue("程序名称或任意值", strPath);
}
}
catch (Exception)
{
ShowMessageOnUI.ShowErrorMessage("打开开机启动设置失败!");
}
finally
{
loca.Close();
}
}
//关闭开机启动
private void SetNotAutoSatrt()
{
RegistryKey loca = Registry.LocalMachine;
try
{
RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
if (run.GetValue("裂帛客服工具") != null)
{
run.DeleteValue("程序名称或任意值");
}
}
catch (Exception)
{
ShowMessageOnUI.ShowErrorMessage("关闭开机启动设置失败!");
}
finally
{
loca.Close();
}
}
?