zoukankan      html  css  js  c++  java
  • 设置程序开机启动

            public Boolean IsStartUp()
            {
                RegistryKey loca = Registry.LocalMachine;
                RegistryKey run = loca.OpenSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun", true);
                //未设置开机启动
                if (run.GetValue("Access Controller") != null)
                {
                    loca.Close();
                    run.Close();
                    return true;
                }
                else
                {
                    loca.Close();
                    run.Close();
                    return false;
                }
    
            }
            // 开机启动注册表检查
            public void StartWindows()
            {
                RegistryKey loca = Registry.LocalMachine;
                RegistryKey run = loca.OpenSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun", true);
                //未设置开机启动
                if (run.GetValue("Access Controller") == null)
                {
                    string starupPath = Application.ExecutablePath;
                    //class Micosoft.Win32.RegistryKey. 表示Window注册表中项级节点,此类是注册表装.
                    //RegistryKey loca = Registry.LocalMachine;
                    //RegistryKey run = loca.CreateSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun");
                    try
                    {
                        run.SetValue("Access Controller", starupPath);
                        //MessageBox.Show("注册表添加成功!", title, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        loca.Close();
                        run.Close();
                    }
                    catch (Exception ee)
                    {
                        PublicClass Publiclass = new PublicClass();
                        Publiclass.MessageBoxTextOk(ee.Message);
                    }
                }
            }
            //取消开机自启
            public void CancelStartUp()
            {
                RegistryKey loca = Registry.LocalMachine;
                RegistryKey run = loca.OpenSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun", true);
                //未设置开机启动
                if (run.GetValue("Access Controller") != null)
                {
                    string starupPath = Application.ExecutablePath;
                    run.DeleteValue("Access Controller");
                }
            }
  • 相关阅读:
    课堂练习02
    第五周进度条
    软件工程个人作业03
    第四周进度条
    构建之法阅读笔记02
    ---JS canvas学习笔记
    JavaScript 对象、DOM对象、jquery对象的区别、转换详解
    JQM---列车时刻查询
    JS---如何避免用户在请求时“猛击”
    HTML5 新增属性和废除属性
  • 原文地址:https://www.cnblogs.com/zhumeng1582/p/3425798.html
Copyright © 2011-2022 走看看