编程方式设置代理服务器地址,端口,用户,密码throught Windows注册表 [英] Programmatically Set Proxy Address, Port, User, Password throught Windows Registry

查看:429
本文介绍了编程方式设置代理服务器地址,端口,用户,密码throught Windows注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写这将使用Internet Explorer与一对夫妇进行交互的网站,从华廷帮助小C#应用程序。

I'm writing a small C# application that will use Internet Explorer to interact with a couple a websites, with help from WatiN.

不过,这也需要不时使用代理。

However, it will also require from time to time to use a proxy.

我碰到编程设置浏览器代理设置在C#中,但这只会使我输入代理服务器地址,我也需要输入代理服务器的用户名和密码。我如何能做到这一点。

I've came across Programmatically Set Browser Proxy Settings in C#, but this only enables me to enter a proxy address, and I also need to enter a Proxy username and password. How can I do that?

请注意:


  • 没关系如果解决方案改变了整个系统的上网设置。不过,我宁愿只改变IE代理设置(任何连接)。

  • 解决方案与IE8和Windows XP SP3或更高版本的工作。

  • 我想必须先读取代理设置的可能性,这样,以后我可以撤消我的变化。

修改

通过访问Windows注册表的帮助下,通过 Microsoft.Win32.RegistryKey ,我能申请代理是这样的:

With the help of the Windows Registry accessible through Microsoft.Win32.RegistryKey, i was able to apply a proxy something like this:

RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", 1);
registry.SetValue("ProxyServer", "127.0.0.1:8080");



但我怎么可以指定一个用户名,并在代理服务器登录密码吗?

But how can i specify a username and a password to login at the proxy server?

我也注意到,IE浏览器不会刷新其连接代理细节一旦注册表被改变如何订购IE从注册表中刷新其连接设置?

I also noticed that IE doesn't refresh the Proxy details for its connections once the registry was changed how can i order IE to refresh its connection settings from the registry?

感谢

推荐答案

有关IE浏览器,可以在注册表中使用相同的地方。只要设置访问代理服务器=用户:password@127.0.0.1:8080。但是火狐完全反对这一点,并不会试图连接

For IE, you can use the same place in the registry. Just set ProxyServer="user:password@127.0.0.1:8080" however firefox completely rejects this, and does not attempt to connect.

这篇关于编程方式设置代理服务器地址,端口,用户,密码throught Windows注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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