简体   繁体   English

在Windows上的C ++中设置系统代理和认证

[英]Set system proxy && authentication in C++ on Windows

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: C ++中有没有一种方法可以用身份验证凭据设置Windows系统代理这样它将立即影响所有正在运行的程序(浏览器等),但:

  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 使用:c ++ 11,Windows 7

EDIT 1: I need to set this programmatically, so please do not suggest any manual actions. 编辑1:我需要以编程方式进行设置,所以请不要建议任何手动操作。
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) 编辑2:部分接受的方法是一种通过编程方式设置代理而不进行预身份验证但仍保持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. 系统级代理服务器设置都位于注册表下的\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings在蜂巢HKLM所有用户和HKCU蜂巢当前用户。 There is an official instruction how to change it via REG file, you does not need to write any code. 有一个官方说明如何通过REG文件进行更改,您无需编写任何代码。

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. 但是主要问题是:任何应用程序可能都有自己的代理设置,其中1)可以选择系统级别的设置,但允许用户覆盖它; 2)完全不使用系统设置。

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) Internet网关不允许直接访问除代理服务器(Microsoft ISA / Forefront Web代理)以外的任何计算机的外部网络
  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. 如果用户需要运行无法使用系统范围的代理设置的应用程序,则需要安装ISA防火墙客户端,该客户端可拦截所有流量并在ISA代理上进行身份验证。

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. 因此,当您使用完整的Microsoft软件堆栈时-您仍然不需要编写任何代码:-)而且,ISA Firewall Client使用未记录的Windows功能,并且很难编写将其替换为自己的“ C ++ 11”的东西。技能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM