views:

435

answers:

2

I want C# code to use Socks 5 proxies in Internet Explorer. I have code for http proxies but that code is not working for Socks proxies.

Anyone has such code? Please provide some pointers...

Iam basically doing IE automation in C#, and I need code to use socks proxies using IE.

+1  A: 

What keeps you from setting

HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\

  • "ProxyEnable" to 1 (enable usage of proxy)
  • "AutoConfigURL" to a *.pac-file (can point to a file on localhost or distantserver)

?

Has the advantage that you can distribute one configuration-file which is easier to update than a binary when changes come up. *.pac files are quite simple:

function FindProxyForURL(url,host) {return"SOCKS my.socksproxy.net:<proxyport>"}


Besides: There is an "official" way: Setting IE-Settings through the Group Policies-API, everything documented on the MSDN. Lets you configure a proxy for every protocol but is not as simple as my first suggestion.

HTH, flokra

flokra
I flokra, I know this process, do you have the code to set the proxy script in C#?
Sumit Ghosh
You'll find examples + explanation on the MSDN: http://msdn.microsoft.com/en-us/library/aa383910%28VS.85%29.aspx
flokra
+1  A: 

IE uses WinINet so if you change WinINet Proxy settings in registry I think it will affect IE and other applications using WinINet.

http://msdn.microsoft.com/en-us/library/ms905660.aspx

Under "Proxy settings" section, it mentioned that this key can be manipulated by WinINet functions. I think it is possible to use PInvoke in C# to call them.

Lex Li