简体   繁体   English

使用代理与Web浏览器控件

[英]Using Proxy with web browser control

is it possible to use two web browser controls with different proxies without writing the registry. 是否可以使用具有不同代理的两个Web浏览器控件而无需编写注册表。

or there might be any solution ? 或者可能有任何解决方案?

You cannot do this with the Web Browser Control. 您无法使用Web浏览器控件执行此操作。 InternetSetOption allows you to set a proxy, but your choices are only "For all processes" or "For this process". InternetSetOption允许您设置代理,但您的选择仅为“For all processes”或“For this process”。 You cannot set the proxy individually for a single control. 您无法单独为单个控件设置代理。 If there's something distinct about the traffic (eg one control goes to 1 server, the other goes to another) you could configure the process to use a Proxy Configuration Script (search for FindProxyForURL) to chain traffic bound for different servers to different proxies. 如果流量存在明显差异(例如,一个控制转到一个服务器,另一个控制转到另一个服务器),您可以将进程配置为使用代理配置脚本(搜索FindProxyForURL)将绑定到不同服务器的流量链接到不同的代理。

If you do set the proxy, you should use InternetSetOption rather than directly manipulating the registry. 如果设置了代理,则应使用InternetSetOption而不是直接操作注册表。

(As a workaround, you COULD put FiddlerCore into your process, set your process to use FiddlerCore, and then have FiddlerCore send traffic from each control to a different upstream gateway, but that requires that you find some way to distinguish traffic from each control.) (作为一种解决方法,您可以将FiddlerCore放入您的进程,将您的进程设置为使用FiddlerCore,然后让FiddlerCore将流量从每个控件发送到不同的上游网关,但这需要您找到一些方法来区分每个控件的流量。 )

Actually I think that writing the registry is the only way because WebBrowser creates an instance of Internet Explorer, so you have to change IE settings modifying the registry. 实际上我认为编写注册表是唯一的方法,因为WebBrowser创建了一个Internet Explorer实例,因此您必须更改修改注册表的IE设置。

If you don't want to change actual configuration you could store proxy address, modify it with yours and then restore it when the application closes. 如果您不想更改实际配置,则可以存储代理地址,使用您的代理地址进行修改,然后在应用程序关闭时将其还原。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM