zoukankan      html  css  js  c++  java
  • C#设置程序自启动

      public static void SetAutoRun(string fileName, bool isAutoRun)
            {
                RegistryKey reg = null;
                try
                {
                    if (!System.IO.File.Exists(fileName))
                    {
                        LogMessage(mlog, mesg, "ITDMS.EXE文件不存在");
                    }
                    string name = fileName.Substring(fileName.LastIndexOf(@"")+1);
                    reg = Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun", true);
                    if (reg == null)
                    {
                        reg = Registry.LocalMachine.CreateSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionRun");
                    }
                    if (isAutoRun)
                    {
                        reg.SetValue(name, fileName);
                    }
                    else
                    {
                        reg.SetValue(name, false);
                    }
                 
                }
                catch (Exception ex)
                {
                    LogMessage(mlog,mesg,ex.ToString());
                }
            }

  • 相关阅读:
    单片机、嵌入式ARM学习网站推荐(多年的积累)
    单片机心得
    printf函数解析
    C语言数组与指针详解
    C语言数组与指针详解
    单片机心得
    单片机、嵌入式ARM学习网站推荐(多年的积累)
    嵌入式开发资料集锦
    poj1941
    poj1723
  • 原文地址:https://www.cnblogs.com/xiaogongzhu/p/3826757.html
Copyright © 2011-2022 走看看