- //打开注册表键
- Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
- //设置代理可用
- rk.SetValue("ProxyEnable", 1);
- //设置代理IP和端口
- rk.SetValue("ProxyServer", TempPoxy);
- rk.Close();
- /// <summary>
- /// 清空ie代理
- /// </summary>
- /// <returns></returns>
- public bool SetCleanIEPoxy()
- {
- try
- {
- //打开注册表键
- Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
- //设置代理不可用
- rk.SetValue("ProxyEnable", 0);
- rk.Close();
- return true;
- }
- catch { return false; }
- }
- //该片段来自于http://www.codesnippet.cn/detail/060120131357.html
来源: http://www.codesnippet.cn/detail/060120131357.html