C#修改注册表

来源:互联网 发布:平阳昭公主 知乎 编辑:程序博客网 时间:2024/06/05 14:33
//注册表修改下载位置                RegistryKey src = Registry.CurrentUser.OpenSubKey("SOFTWARE", true).OpenSubKey(@"Microsoft\\Internet Explorer", true);                if (src.Name.Length > 0)                {                    Debug.WriteLine("下载时路径改为:" + NewDirectory);                    src.SetValue("Download Directory", NewDirectory);                }



//获取原来的IE保存路径            RegistryKey src = Registry.CurrentUser.OpenSubKey("SOFTWARE", true).OpenSubKey(@"Microsoft\\Internet Explorer", true);            if (src.Name.Length > 0)            {                var s = src.GetValue("Download Directory");                OldDirectory = s.ToString();                Debug.WriteLine("初始化 老地址:" + OldDirectory);                logger.Info("初始化 老地址:"+OldDirectory);                           }