• 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());
                }
            }

  • 相关阅读:
    B. Vova and Trophies 字符串预处理+思维+贪心
    Got error 28 from storage engine
    TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
    mysql复制问题
    upgrade mysql
    replica set remove member
    Perl安装及环境配置
    Django
    mongo collection name—SyntaxError: identifier starts immediately after numeric literal
    MySQL 单表flashback
  • 原文地址:https://www.cnblogs.com/xiaogongzhu/p/3826757.html
Copyright © 2020-2023  润新知