我正在为Windows编写一个命令行工具,它使用libcurl从Internet下载文件.
显然,当用户在代理服务器后面时,下载不起作用,因为需要配置代理.我希望尽可能简化我的工具,而不必为用户配置代理负担.我的工具甚至没有配置文件,因此用户否则必须在每个命令上传递代理设置,或设置环境变量或某些 - 太麻烦了.
所以我想,每个人的浏览器通常都已经正确设置,代理配置和一切.即使是最基本的用户也是如此,否则"他们的互联网将无法正常工作".
所以我认为我可以通过查看IE的代理设置来了解是否使用代理.
我该怎么做?进一步来说:
在人们开始建议替代方案之前:我正在使用C,所以我只限于Win32 API,我真的很想继续使用C和libcurl.
是否可以检测/重用这些设置?
怎么样 ?
我得到的例外情况是这是连接到http://www.google.com时的例外情况
System.Net.WebException: Unable to connect to the remote server --->
System.Net.Sockets.SocketException: A connection attempt failed because the
connected party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond 66.102.1.99:80
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
Socket s4, Socket s6, Socket& socket, IPAddress& address,
ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout,
Exception& exception)
--- End of inner exception stack trace --- …Run Code Online (Sandbox Code Playgroud)