I try figure out, why gcc/g++ compiler throw error likie this:
.\http.cpp: In function 'int main()':.\http.cpp:14:5: error: 'WinHttpOpen' was not declared in this scope WinHttpOpen( L"A WinHTTP Example Program/1.0", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
Below i put my code. It is pretty weird, because i wrote that code according to in MSDN Documentation.
#include <stdio.h>#include <winhttp.h>#pragma comment(lib, "winhttp.lib");using namespace std;int main(void){ bool bResults = false; // HINTERNET hSession = NULL; // HINTERNET hConnect = NULL; // HINTERNET hRequest = NULL; // Use WinHttpOpen to obtain a session handle. WinHttpOpen( L"A WinHTTP Example Program/1.0", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); // Specify an HTTP server. // if (hSession) // hConnect = WinHttpConnect( hSession, L"www.wp.pl", // INTERNET_DEFAULT_HTTP_PORT, 0); // // Create an HTTP Request handle. // if (hConnect) // hRequest = WinHttpOpenRequest( hConnect, L"GET", // L"/writetst.txt", // NULL, WINHTTP_NO_REFERER, // WINHTTP_DEFAULT_ACCEPT_TYPES, // 0); // Send a Request. // if (hRequest) // bResults = WinHttpSendRequest( hRequest, // WINHTTP_NO_ADDITIONAL_HEADERS, // 0, WINHTTP_NO_REQUEST_DATA, 0, // 0, 0); // Place additional code here. // Report errors. // if (!bResults) // printf("Error %d has occurred.\n",GetLastError()); // // Close open handles. // if (hRequest) WinHttpCloseHandle(hRequest); // if (hConnect) WinHttpCloseHandle(hConnect); // if (hSession) WinHttpCloseHandle(hSession); return 0;}
Do you have any suggestion?I commented out part of code, but it really doesn't matter, error is always the same.