2011-07-06 72 views
0

我試圖更改'WinHttpSettings'註冊表值,但它給出錯誤。我試着像下面要更改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'

+0

什麼是錯誤! –

+0

'無法寫入註冊表項。' – deepi

回答

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. 
+0

現在它將值更改爲'0 * 00000000(1)',但我想將值更改爲'0000',即在它具有某個十六進制值之前,我想移除該 – deepi

+0

不確定是否理解您的目標。你怎麼寫四個1字節,而不是四個0? –

+0

看到我編輯它的問題 – deepi