欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

c# 開機(jī)啟動項(xiàng)的小例子

 更新時(shí)間:2013年03月20日 14:24:50   作者:  
c# 開機(jī)啟動項(xiàng)的小例子,需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

  //路徑, 添加開機(jī)啟動/刪除開機(jī)啟動

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

        }

相關(guān)文章

最新評論