首页 新闻 会员 周边 捐助

C#修改注册表IE代理设置,如何做到无需重启IE使代理生效

0
悬赏园豆:30 [已关闭问题]
using System; <BR>using Microsoft.Win32; <BR>using System.Diagnostics; <BR><BR>public class ChangProxy <BR>{ <BR>&nbsp; &nbsp; public static void Main(string[] args) <BR>&nbsp; &nbsp; { <BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; int Proxy_Enabled; <BR>&nbsp; &nbsp; &nbsp; &nbsp; RegistryKey rkey = Registry.CurrentUser; <BR>&nbsp; &nbsp; &nbsp; &nbsp; RegistryKey software = rkey.OpenSubKey("Software"); <BR>&nbsp; &nbsp; &nbsp; &nbsp; RegistryKey microsoft = software.OpenSubKey("Microsoft"); <BR>&nbsp; &nbsp; &nbsp; &nbsp; RegistryKey windows = microsoft.OpenSubKey("Windows"); <BR>&nbsp; &nbsp; &nbsp; &nbsp; RegistryKey currentversion = windows.OpenSubKey("CurrentVersion"); <BR>&nbsp; &nbsp; &nbsp; &nbsp; RegistryKey internetsettings = currentversion.OpenSubKey("Internet Settings", true); <BR>&nbsp; &nbsp; &nbsp; &nbsp; Proxy_Enabled = Convert.ToInt32(internetsettings.GetValue("ProxyEnable")); <BR>&nbsp; &nbsp; &nbsp; &nbsp; if (Proxy_Enabled != 1) <BR>&nbsp; &nbsp; &nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; internetsettings.SetValue("ProxyEnable", 1); <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Microsoft.VisualBasic.Interaction.Beep(); <BR>&nbsp; &nbsp; &nbsp; &nbsp; } <BR>&nbsp; &nbsp; &nbsp; &nbsp; else <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; internetsettings.SetValue("ProxyEnable", 0); <BR>&nbsp; &nbsp; } <BR>} <BR><BR>以上为代码,通过读取注册表中的ProxyEnable的键值判断IE是否使用代理,如果使用了代理则取消代理,如果未使用代理则加上代理设置. <BR><FONT color=#ff0000 size=3>问题是,每次通过修改注册表键值更改IE代理设置状态后都必须重启IE才能使代理设置生效. <BR>请问各位达人,如何做到无需重启IE即可使IE代理设置变更生效?</FONT> <BR>谢谢.小弟在线等.
eecc的主页 eecc | 初学一级 | 园豆:41
提问于:2008-06-04 19:52
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册