Win窗体中的Web浏览器控件 [英] Web Browser Control in Win Forms

查看:80
本文介绍了Win窗体中的Web浏览器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Windows窗体中的WebBrowser-Control导航到指定的网站或网页.但是如何通过代理服务器连接?如何设置代理服务器的用户名,密码和端口? etc

I want to navigate to e specified Website or web page with the WebBrowser-Control in Windows Forms. But how to connect through a proxy server ? How to set the proxy server user name,password and port? etc

推荐答案

也在寻找以下内容,并在以下站点上找到了它.
大约下降一半.

设置代理服务器

您似乎需要导入非托管代码,但看起来可以解决问题.

希望这对您有所帮助.
Was looking for the following as well and found it on the following site.
About half way down.

Set Proxy

You need to import unmanaged code it seems, but looks like it will do the trick.

Hope this helps.


由于WebBrowser控件只不过是IE的一个实例,因此您可以从注册表中获取代理设置.

您可以通过这种方式进行操作(但由于它会操纵注册表,因此可能需要您的应用具有管理员权限):

Since the WebBrowser control is nothing more thanan instance of IE, you can get the proxy settings from the registry

You could do it this way (but since it manipulates the registry, it may require your app to have admin rights):

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);




当然,如果您不使用IE,则可能需要更改.




Of course, if you''re not using IE, this will probably need to change.


这篇关于Win窗体中的Web浏览器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆