更改WinHttpSettings注册表值

时间:2011-07-06 04:22:59

标签: c# registry

我正在尝试更改'WinHttpSettings'注册表值,但它给出了错误。我尝试过如下

       RegistryKey OurKey = Registry.LocalMachine;
        //MessageBox.Show(OurKey.ToString());
        RegistryKey local = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections");
        string value = local.GetValue("WinHttpSettings").ToString();
        byte[] b ={ 1, 1, 1, 1 };
        if (value != null)
        {
            local.SetValue("WinHttpSettings",b);
            //MessageBox.Show(value.ToString());
        }

我在上述代码或任何其他解决方案中所犯的任何错误

在注册表之前,值如下所示:

before

做完'史蒂夫B'后告诉改变:

 RegistryKey local = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections",true);

enter image description here

但我想要的是将第一个图像值更改为“0000”

1 个答案:

答案 0 :(得分:0)

更改此行:

RegistryKey local = Registry.LocalMachine.OpenSubKey(
    @"SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections",
    true
    );

特别注意true作为第二个参数。正如documentation中所解释的那样,它的用途是:

 writable Type: System.Boolean 
 Set to true if you need write access to the
 key.