Thursday, May 24, 2012

Change Proxy C# example

ye i know there r millions exapmle but i wanna point out 2 thing:       
string todaysProxy = "192.168.0.254:3128";
RegistryKey registry = Registry.CurrentUser.OpenSubKey
             ("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", "00000001", RegistryValueKind.DWord);
registry.SetValue("ProxyEnable", 1);
registry.SetValue("ProxyServer", todaysProxy);
registry.SetValue("ProxyOverride", "192.168.0.*;127.0.0.*;localhost");

1 - ProxyEnable - either int 1 or define kind, unlike the batch
2 - O.C. IT WONT TAKE IMMIDIATE AFFECT but only on the new sessions, unless:
http://stackoverflow.com/questions/2020363/how-to-change-global-windows-proxy-using-c-sharp-net-with-immediate-effect

No comments:

Post a Comment