开机自启动
📌
开机启动设置
在使用的时候不要双击去点击这个按钮生成一个事件 ,而是通过代码去进行一个创建:

代码展示:
#region 开机启动
/// <summary>
/// 修改程序在注册表中的键值
/// </summary>
/// <param name="isAuto">true:开机启动,false:不开机自启</param>
private void AutoStart(bool isAuto = true)
{
if (isAuto == true)
{
RegistryKey R_local = Registry.CurrentUser;
RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
R_run.SetValue("PressurizationStationPro", System.Windows.Forms.Application.ExecutablePath);
R_run.Close();
R_local.Close();
}
else
{
RegistryKey R_local = Registry.CurrentUser;
RegistryKey R_run = R_local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
R_run.DeleteValue("PressurizationStationPro", false);
R_run.Close();
R_local.Close();
}
}
#endregion

开机自启动代码展示
浙公网安备 33010602011771号