UNKNOWN //************************************** // Name: cpp code to find system proxy settings (windows) // Description:CPP code to detect system proxy in windows. It uses api - WINHTTP_CURRENT_USER_IE_PROXY_CONFIG // By: infant_coder // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //This code is copyrighted and has limited warranties. //Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.13383/lngWId.3/qx/vb/scripts/ShowCode.htm //for details. //************************************** /* Cpp Program to find the proxy settings in windows PC. Author: Infant_coder. */ #include "stdafx.h" #include <Windows.h> #include <Winhttp.h> using namespace std; void main() { WINHTTP_CURRENT_USER_IE_PROXY_CONFIG MyProxyConfig; if(!WinHttpGetIEProxyConfigForCurrentUser(&MyProxyConfig)) { //check the error DWORD Err = GetLastError(); cout << "WinHttpGetIEProxyConfigForCurrentUser failed with the following error number: " << Err << endl; switch (Err) { case ERROR_FILE_NOT_FOUND: cout << "The error is ERROR_FILE_NOT_FOUND" << endl; break; case ERROR_WINHTTP_INTERNAL_ERROR: cout << "ERROR_WINHTTP_INTERNAL_ERROR" << endl; break; case ERROR_NOT_ENOUGH_MEMORY: cout << "ERROR_NOT_ENOUGH_MEMORY" << endl; break; default: cout << "Look up error in header file." << endl; }//end switch }//end if else { //no error so check the proxy settings and free any strings cout << "Auto Detect is: " << MyProxyConfig.fAutoDetect << endl; if(NULL != MyProxyConfig.lpszAutoConfigUrl) { wcout << "AutoConfigURL is: " << MyProxyConfig.lpszAutoConfigUrl << endl; GlobalFree(MyProxyConfig.lpszAutoConfigUrl); } if(NULL != MyProxyConfig.lpszProxy) { wcout << "AutoConfigURL is: " << MyProxyConfig.lpszProxy << endl; GlobalFree(MyProxyConfig.lpszProxy); } if(NULL != MyProxyConfig.lpszProxyBypass) { wcout << "AutoConfigURL is: " << MyProxyConfig.lpszProxyBypass << endl; GlobalFree(MyProxyConfig.lpszProxyBypass); } }//end else cout << "finished!"; }//end main /* # Start Microsoft Visual Studio .NET. # On the File menu, point to New, and then click Project. # Under Project Types, click Visual C++ Projects. # Under Templates, click Win32 Project. # In the Name box, type proxy_test, and then click OK. # On the Welcome to the Win32 Application Wizard page, click Application Settings. # Under Application type, click Console application, and then click Finish. The proxy_test.cpp file is created. # Replace the existing code in the proxy_test.cpp file with the following code: # On the Project menu, click Properties. # In the left pane, double-click Linker. # Under Linker, click Input. # In the right pane, type winhttp.lib in the Additional Dependencies field, and then click OK. # On the Build menu, click Build Solution. */