I'm writing a winform's (C# .NET) app to change Window's Global (aka internet explorer's) proxy settings.
I'm using this.
RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", 1);
registry.SetValue("ProxyServer", "127.0.0.1:8080");
But its behaving in weird manner. I tested this using two browsers
- Google Chrome:
When I change/Disable the proxy while Chrome is running. Chrome is still using the previous proxy. The change is not effecting its process. But when I JUST open Internet Options(inet.cpl) > Connections > Lan Settings
. The previous change of proxy is now considered. When I said Just open I really mean Just open. I mean, not editing or clicking any other buttons. I guess, its then the global proxy is really getting changed (by reading from registry) & Google Chrome is immediately taking the effect.
- Internet Explorer 8:
Case with Internet Explorer is much worse. After changing/disabling the proxy using my app while IE is running & Even after going to "Internet Options(inet.cpl) > Connections > Lan Settings" The running IE proxy isn't getting effected. Not even if I open a new link in a new tab. I had to restart IE for that change to be incorporated.
I the behavior I want is that when ever I change proxy settings in my app, all the browsers which are using global proxy (irrespective of whether they are running or not) should instantly incorporate the change in settings.
How can I achieve this?