从注册表中获取,c# 代码
// 是否启用代理
private bool GetProxyStatus()
{
//打开注册表
RegistryKey regKey = Registry.CurrentUser;
string SubKeyPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
RegistryKey optionKey = regKey.OpenSubKey(SubKeyPath, true); //更改健值,设置代理,
int actualProxyStatus = Convert.ToInt32(optionKey.GetValue("ProxyEnable"));
regKey.Close();
return actualProxyStatus == 1 ? true : false;
}
// 代理地址
private string GetProxyServer()
{
//打开注册表
RegistryKey regKey = Registry.CurrentUser;
string SubKeyPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
RegistryKey optionKey = regKey.OpenSubKey(SubKeyPath, true); //健值,设置代理,
var actualProxy = optionKey.GetValue("ProxyServer");
regKey.Close();
if (actualProxy == null)
return "";
return actualProxy.ToString();
}
// 对于本地地址不使用代理服务器
private bool GetProxyPassLocal()
{
//打开注册表
RegistryKey regKey = Registry.CurrentUser;
string SubKeyPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
RegistryKey optionKey = regKey.OpenSubKey(SubKeyPath, true); //健值,设置代理,
var ProxyOverride = optionKey.GetValue("ProxyOverride");
regKey.Close();
if (ProxyOverride == null)
return false;
if (ProxyOverride.ToString() == "<local>")
return true;
return false;
}