Ale*_*fie 8 .net c# vb.net windows networking
我正在编写一个程序,根据我连接的网络自动切换代理地址.
到目前为止,我已经完成了所有工作,除了我在下面重点介绍的部分.

有没有办法更改自动配置脚本和自动检测代码中的设置?
解决方案可以是P/Invoke注册表编辑.我只需要一些有用的东西.
ich*_*hen 18
您可以使用注册表更改代理设置.请参阅以下链接:http:
//support.microsoft.com/kb/819961
关键路径: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
价值观:
"MigrateProxy"=dword:00000001
"ProxyEnable"=dword:00000001
"ProxyHttp1.1"=dword:00000000
"ProxyServer"="http://ProxyServername:80"
"ProxyOverride"="<local>"
Run Code Online (Sandbox Code Playgroud)
一个在SuperUser.com问题有关如何禁用自动检测IE代理的配置设置.禁用IE代理配置中的"自动检测设置"
一个片段,通过注册表从Internet Explorer自动配置脚本定义中获取.
脚本1:这将启用AutoConf脚本并定义它是什么(与您的脚本交换http:// xxxx)
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings] "AutoConfigURL"="http://xxx.xxx.xxx.xxx.xxxx" "ProxyEnable"=dword:00000000
脚本2:此脚本禁用AutoConf脚本并启用具有例外的代理服务器.
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings] "ProxyEnable"=dword:00000001 "ProxyOverride"="proxyexceptionname:portnumber;anotherexceptionname:port "ProxyServer"="ftp=MyFTPProxy:Port;http=MYHTTPPROXY:PORT;https=MYHTTPSPROXY:PORT "AutoConfigURL"=""
小智 8
我一直在寻找这个.但是,由于我无法找到,我编写了以下代码片段,可用于此目的.
/// <summary>
/// Checks or unchecks the IE Options Connection setting of "Automatically detect Proxy"
/// </summary>
/// <param name="set">Provide 'true' if you want to check the 'Automatically detect Proxy' check box. To uncheck, pass 'false'</param>
public void IEAutoDetectProxy(bool set)
{
// Setting Proxy information for IE Settings.
RegistryKey RegKey = Registry.CurrentUser.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Connections", true);
byte[] defConnection = (byte[])RegKey.GetValue("DefaultConnectionSettings");
byte[] savedLegacySetting = (byte[])RegKey.GetValue("SavedLegacySettings");
if (set)
{
defConnection[8] = Convert.ToByte(9);
savedLegacySetting[8] = Convert.ToByte(9);
}
else
{
defConnection[8] = Convert.ToByte(1);
savedLegacySetting[8] = Convert.ToByte(1);
}
RegKey.SetValue("DefaultConnectionSettings", defConnection);
RegKey.SetValue("SavedLegacySettings", savedLegacySetting);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
37818 次 |
| 最近记录: |