How do I use a socket proxy in C# webbrowser?

2019-01-19 23:07发布

How do I point a socket to the proxy ip/port using the winforms webbrowser control? The standard web browser that comes with Visual C#.NET.

Please help in Visual C#.NET.

2条回答
做个烂人
2楼-- · 2019-01-19 23:35

WebBrowser is just an interface over IE. To set the IE proxy settings, you can hack the registry!

        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);
查看更多
Deceive 欺骗
3楼-- · 2019-01-19 23:37

The WebBrowser control is just a wrapper around IE. So to set proxy settings, you could change the registry key entries.

Something like this:

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);
查看更多
登录 后发表回答