Showing posts with label proxy. Show all posts
Showing posts with label proxy. Show all posts

Monday, May 29, 2017

How to Set Internet explorer proxy from code behind

using Microsoft.Win32;

private void SetIeProxy(string Proxy)
 {
         RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
         registry.SetValue("ProxyServer", Proxy);
         registry.SetValue("ProxyEnable", 1);
 
         // These lines implement the Interface in the beginning of program
         // They cause the OS to refresh the settings, causing IP to realy update
         bool settingsReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
         bool refreshReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
 }