Created
September 4, 2020 10:48
-
-
Save ijat/842b97dffc03ceb106c6af159a61b87f to your computer and use it in GitHub Desktop.
Test winhttpopen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <Windows.h> | |
#include <winhttp.h> | |
#pragma comment(lib, "winhttp.lib") | |
int main() { | |
DWORD data; | |
DWORD dwSize = sizeof(DWORD); | |
// Use WinHttpOpen to obtain an HINTERNET handle. | |
HINTERNET hSession = WinHttpOpen(L"privacyidea-cp", | |
WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, | |
WINHTTP_NO_PROXY_NAME, | |
WINHTTP_NO_PROXY_BYPASS, 0); | |
if (hSession) | |
{ | |
// Use WinHttpQueryOption to retrieve internet options. | |
if (WinHttpQueryOption(hSession, | |
WINHTTP_OPTION_CONNECT_TIMEOUT, | |
&data, &dwSize)) | |
{ | |
printf("Connection timeout: %u ms\n\n", data); | |
} | |
else | |
{ | |
printf("Error %u in WinHttpQueryOption.\n", | |
GetLastError()); | |
} | |
// When finished, release the HINTERNET handle. | |
WinHttpCloseHandle(hSession); | |
} | |
else | |
{ | |
printf("Error %u in WinHttpOpen.\n", GetLastError()); | |
} | |
std::string lol; | |
std::cin >> lol; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment