Set system proxy && authentication in C++ on Windows

3.1k views Asked by At

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)

1

There are 1 answers

5
vitalyster On

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.