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

后端 未结 2 1146
挽巷
挽巷 2020-12-11 09:00

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#.

相关标签:
2条回答
  • 2020-12-11 09:05

    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);
    
    0 讨论(0)
  • 2020-12-11 09:20

    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);
    
    0 讨论(0)
提交回复
热议问题