There are 2 ways:
easy: call
InternetOpenUrl()
with a dummy URL to letwininet
initialize jsproxy:#define URL "https://yandex.ru:777" #define HOST "yandex.ru" HINTERNET hInternet = InternetOpen(_T("try-wininet"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); HINTERNET hUrl = InternetOpenUrl(hInternet, _T("http://0.0.0.0"), NULL, 0, 0, 20); InternetCloseHandle(hUrl); InternetCloseHandle(hInternet); InternetGetProxyInfo(URL,sizeof(URL)-1,HOST,sizeof(HOST)-1, &str, &nb); GlobalFree(str);
hard: call
InternetInitializeAutoProxyDll()
in jsproxy. But to prepare the arguments, you have to do everything yourself: read the settings from the registry, parse them, detect and download the PAC file and provide an implementation ofAutoProxyHelperVtbl
that contains such functions asGetIPAddress()
,IsInNet()
, etc.
InternetGetProxyInfo()
fails when there's no PAC script configured, although some proxy server is set in the bottom of the dialog. In this case you should call InternetQueryOption(NULL, INTERNET_OPTION_PROXY,...)