2011-06-05 32 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