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))
                        throw new Exception("该文件不存在!");
                    String name = fileName.Substring(fileName.LastIndexOf(@"\") + 1);
                    reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
                    if (reg == null)
                        reg = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
                    if (isAutoRun)
                        reg.SetValue(name, fileName);
                    else
                        reg.SetValue(name, false);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.ToString());
                }
                finally
                {
                    if (reg != null)
                        reg.Close();
                }

            }

  • 相关阅读:
    谷歌浏览器禁止缩放和全面屏显示
    常用正则表达式
    封装时间函数
    年月日,时分秒,星期
    昨天,明天,月初,月末,最近七天,最近一个月,今天零时js
    React框架
    javaweb基础备忘
    一些java基础知识的备忘
    查看deepin版本
    java中堆栈的一些理解备忘
  • 原文地址:https://www.cnblogs.com/weloglog888/p/2971087.html
Copyright © 2011-2022 走看看