开发者

How to set internet Proxy and Port without affecting the SYSTEM/IE proxy

开发者 https://www.devze.com 2023-03-16 05:50 出处:网络
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\\\

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:

How to set internet Proxy and Port without affecting the SYSTEM/IE proxy

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号