首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#设立写注册表,设置程序开机启动

2012-09-07 
C#设置写注册表,设置程序开机启动//打开开机启动private void SetAutoStart(){string strPath Applicati

C#设置写注册表,设置程序开机启动

//打开开机启动        private void SetAutoStart()        {            string strPath = Application.ExecutablePath;            RegistryKey loca = Registry.LocalMachine;            try            {                RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");                if (run.GetValue("裂帛客服工具") == null)                {                    run.SetValue("程序名称或任意值", strPath);                }            }            catch (Exception)            {                ShowMessageOnUI.ShowErrorMessage("打开开机启动设置失败!");            }            finally            {                loca.Close();            }        }        //关闭开机启动        private void SetNotAutoSatrt()        {            RegistryKey loca = Registry.LocalMachine;            try            {                RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");                if (run.GetValue("裂帛客服工具") != null)                {                    run.DeleteValue("程序名称或任意值");                }            }            catch (Exception)            {                ShowMessageOnUI.ShowErrorMessage("关闭开机启动设置失败!");            }            finally            {                loca.Close();            }        }

?

热点排行