📄 ieconfig.cs
字号:
namespace Imps.Utils
{
using Microsoft.Win32;
using System;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
public static class IeConfig
{
public static bool ReadIeHttpProxySetting(out string proxyServer, out int? proxyPort)
{
proxyServer = null;
proxyPort = null;
try
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings"))
{
if (Convert.ToBoolean(key.GetValue("ProxyEnable")))
{
string input = key.GetValue("ProxyServer") as string;
Match match = Regex.Match(input, @"http\s*=\s*(.*?)\s*:\s*(\d+)", RegexOptions.IgnoreCase);
if (!match.Success && (input.IndexOf('=') == -1))
{
match = Regex.Match(input, @"^(.*?)\s*:\s*(\d+)$", RegexOptions.IgnoreCase);
}
if (match.Success)
{
proxyServer = match.Groups[1].Value;
proxyPort = new int?(int.Parse(match.Groups[2].Value));
return true;
}
}
}
}
catch (Exception)
{
}
return false;
}
public static bool ReadIeSocksProxySetting(out string proxyHost, out int? proxyPort)
{
proxyHost = null;
proxyPort = null;
try
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings"))
{
if (Convert.ToBoolean(key.GetValue("ProxyEnable")))
{
Match match = Regex.Match(key.GetValue("ProxyServer") as string, @"socks\s*=\s*(.*?)\s*:\s*(\d+)", RegexOptions.IgnoreCase);
if (match.Success)
{
proxyHost = match.Groups[1].Value;
proxyPort = new int?(int.Parse(match.Groups[2].Value));
return true;
}
}
}
}
catch (Exception)
{
}
return false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -