How to set internet Proxy and Port without affecting the SYSTEM/IE proxy
I use this code in order to chan开发者_如何学Cge proxy of internet in my C# application:
RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true);
registry.SetValue("ProxyEnable", 1);
registry.SetValue("ProxyServer", "127.0.0.1:80);
settingsReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0);
refreshReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_REFRESH, IntPtr.Zero, 0);
After running the program, when I go to internet properties in IE, I can see that Proxy server has been changed:
My question: How can I change Proxy without affecting IE settings. I mean that when proxy is changed, If I check Internet properties, no changes are made.
I don't know for sure but I think it looks like they intercept calls being made to winsock and modify them to be proxyaware. So effectively every time you create a network call out of your program it gets caught by your proxy-prog which passes it on to winsock with proxying information added.
IP or winsock interception? seems to ask a very similar question so exploring the answer on that might give you the answer. That is just about trying to read a network connection but some of the googling I've done does suggest that a Layered Service Provider could be what you need and that Detours might also be something to look at.
精彩评论