0

Is there a way in C++ to set the Windows system proxy with authentication credentials so it would affect all running programs(browsers, etc...) immediatly but:

  1. Not requiring restarting any browser
  2. Not requiring browser-reauthentication

I am looking really for a system level pre-authenticated proxy.

Thank you for any help. Ask any questions if something is unclear.

Using: c++11, Windows 7

EDIT 1: I need to set this programmatically, so please do not suggest any manual actions.
EDIT 2: Partially acceptable is a way how to set proxy programmatically without pre-authentication but still keeping 1. requirement (Not requiring restarting any browser)

jave.web
  • 13,880
  • 12
  • 91
  • 125
  • Are you willing to use 3rd party libraries to make this happen or natively in your code? – positron Nov 27 '14 at 18:27
  • @positron Why not, I just want to achieve the goal - preauthenticated proxy set on system level :) I am using Windows' libraries anyway... – jave.web Nov 28 '14 at 13:00

1 Answers1

1

System-level proxy settings are located in registry under \Software\Microsoft\Windows\CurrentVersion\Internet Settings hive in HKLM for all users and HKCU hive for current user. There is an official instruction how to change it via REG file, you does not need to write any code.

But the main problem is: any application may have its own proxy settings, where it 1) can prefer system level settings but allow to override it by user, 2) not using system settings at all.

In corporate environments this problem solves as:

  1. Internet gateway not allowed directly access to external network any computer except proxy server (Microsoft ISA/Forefront Web Proxy)
  2. Proxy settings in registry are forced to all computers via Group Policies
  3. If user need to run application which can not use system-wide proxy settings - it need to install ISA Firewall Client which intercepts all traffic and authenticate it on the ISA proxy.

So when you use full Microsoft software stack - you still not need to write any code :-) Moreover, ISA Firewall Client uses undocumented Windows features and it will be too hard to write something to replace it with your own "C++11" skills.

vitalyster
  • 4,980
  • 3
  • 19
  • 27
  • Those settings don't appear to include a password. But I suppose the OP could point them to a proxy server running locally on the box, and have that proxy server forward the requests via the authenticated proxy. – Harry Johnston Nov 28 '14 at 03:12
  • Well, your "C++11 code" will be "int main() { system("reg add settings.reg");}" And BTW - changing proxy settings **DOES NOT** require browser to restart. – vitalyster Nov 28 '14 at 12:21
  • Yes, I have mentioned it in my answer - you can not control applications that use own proxy settings instead of microsoft one. You can "raise change notice" calling `RegNotifyChangeKeyValue` for proxy settings keys, and good application will re-read it, but many other applications will still use old data. There is no ultimate solution and you need to find solution for concrete application you are using. – vitalyster Nov 28 '14 at 12:38
  • @vitalyster btw sorry I've mistunderstood you before - of course changing the settings - just changing them - does not require browser restart (it's a registry...) I was talking about changing it in the browser/app => in other words reloading it :) – jave.web Nov 28 '14 at 14:28
  • Just tested `RegNotifyChangeKeyValue` for `HKEY_CURRENT_USER` => at least Chrome does not get it. – jave.web Nov 28 '14 at 18:44