首页 > Windows开发 > 详细

C# 开机自动启动

时间:2017-10-29 16:19:22      阅读:298      评论:0      收藏:0      [点我收藏+]
       if (ConfigurationManager.AppSettings["IsBoot"].ToString().Trim().ToUpper() == "TRUE")
            {
                //设置开机启动
                string path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                RegistryKey rk = Registry.LocalMachine;
                RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
                rk2.SetValue("JcShutdown", path);
                rk2.Close();
                rk.Close();

            }
            else
            {
                string path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                RegistryKey rk = Registry.LocalMachine;
                RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
                rk2.DeleteValue("JcShutdown", false);
                rk2.Close();
                rk.Close();
            }

App.Config:

  <!--是否开机启动 TRUE 启动 FALSE 禁止-->
  <add key="IsBoot" value="FALSE"/>


  

 

 

C# 开机自动启动

原文:http://www.cnblogs.com/haibing0107/p/7750291.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!