2011-06-05 75 views

回答

4

WebBrowser控件只是IE的一個包裝。因此,要設置代理設置,您可以更改註冊表項條目。

事情是這樣的:

string serverName = ""; // your proxy server name 
string port = ""; // your proxy port 

var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true); 
key.SetValue("ProxyServer", serverName + ":" + port); 
key.SetValue("ProxyEnable", 1); 
+0

我認爲有一些缺失...... RegistryKey告訴我,它不存在於當前的上下文中,我可能會缺少使用指令或程序集引用。怎麼了? – Alper 2011-06-06 02:28:38

+0

@Jacob - 'using Microsoft.Win32;' – 2011-06-06 02:47:58

1

web瀏覽器只是在IE瀏覽器的接口。要設置IE代理設置,你可以破解註冊表!

 string key = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; 
     string serverName = "";//your proxy server name; 
     string port = ""; //your proxy port; 
     string proxy = serverName + ":" + port; 

     RegistryKey RegKey = Registry.CurrentUser.OpenSubKey(key, true); 
     RegKey.SetValue("ProxyServer", proxy); 
     RegKey.SetValue("ProxyEnable", 1); 
+0

我認爲有些東西缺少...... RegistryKey告訴我它在當前上下文中不存在,我可能會缺少使用指令或程序集引用。怎麼了? – Alper 2011-06-06 02:26:27

+0

'using Microsoft.Win32;'See http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey(VS.71).aspx – 2011-06-06 02:32:00

+0

好的,謝謝。 – Alper 2011-06-06 02:42:02