C# 更改WinHttpSettings注册表值的步骤

C# 更改WinHttpSettings注册表值的步骤,c#,registry,C#,Registry,我正在尝试更改“WinHttpSettings”注册表值,但出现错误。我试着像下面一样 RegistryKey OurKey = Registry.LocalMachine; //MessageBox.Show(OurKey.ToString()); RegistryKey local = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Inte

我正在尝试更改“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());
        }
我在上述代码或任何其他解决方案中犯的任何错误

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

在做了“史蒂夫B”之后,他告诉变革:

 RegistryKey local = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections",true);
但我想要的是将第一个图像值更改为“0000”

更改这一行:

RegistryKey local = Registry.LocalMachine.OpenSubKey(
    @"SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections",
    true
    );
特别是,请注意true作为第二个参数。如中所述,其用途是:

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

'无法写入注册表项。'现在它将值更改为'0*00000000 1',但我想将值更改为'0000',也就是说,在它具有某些十六进制值之前,我想删除该值。我不确定是否理解您的目标。你写的是4个1字节,而不是4个0吗?还是不明白。。。。put byte[]b={0,0,0,0}如果您想用0填充4个字节,当我手动删除0个字节时,它会显示为“0 0 0”,您还可以使用local.SetValueWinHttpSettings,b,RegistryValueKind.Binary强制值的类型,以保持与上一版本相同的类型;