title: Change proxy of IE c# for win 7 64 bit(test using httperbrequest to make sure registry change)
body: <p>I have been testing my application on 32 bit and it is working fine but as soon it switches to 64 bit OS then there is a problem </p>
  
  <blockquote>
    <p>it changes proxy for one time but
    never again it keeps and tests same
    proxy for the rest of the loop</p>
  </blockquote>
  
  <p>.I came across some posts that shows that there is some difference bit 32 and 64 bit registry and have written a code but it dose not work well on 64 bit environment   </p>
  
  <pre><code>[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] 
  
  
  [return: MarshalAs(UnmanagedType.Bool)] 
  public static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool lpSystemInfo);
  
  public bool Is64Bit()
  {
      bool retVal;
  
      IsWow64Process(System.Diagnostics.Process.GetCurrentProcess().Handle, out retVal);
  
      return retVal;
  } 
  
  Microsoft.Win32.RegistryKey registry;
  if (Is64Bit())
  {
      MessageBox.Show("Oh HO! you are running 64 bit version");
       registry = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
  }
  else
  {
      MessageBox.Show("Yes it is 32 bit");
       registry = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
  }
  
  string orignalProxyServer = registry.GetValue("ProxyServer").ToString();
  int orignalProxyEnable = int.Parse(registry.GetValue("ProxyEnable").ToString());
  int i = 0;
  
  while (i &lt; listBox1.Items.Count)
  {
  
      //Enter new proxies Settings//
      registry.SetValue("ProxyEnable", 1);
      registry.SetValue("ProxyServer", listBox1.Items[i].ToString());
      RefreshInternetExplorerSettings();
  
      try
      {
          HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.whatismyip.com/automation/n09230945.asp");
          using (StreamReader reader = new StreamReader(req.GetResponse().GetResponseStream()))
          {
              resopnse = reader.ReadToEnd();
              this.Invoke(new EventHandler(DoIe));                       
  
          }
      }
      catch (Exception c)
      {
          MessageBox.Show(c.Message);
  
      }
      i++;
      Application.DoEvents();
      backgroundWorker1.ReportProgress(i);
  }
  registry.SetValue("ProxyEnable", orignalProxyEnable);
  registry.SetValue("ProxyServer", orignalProxyServer);
  RefreshInternetExplorerSettings();
  </code></pre>