然后我继续编写以下代码:
#include <iostream>
#include <windows.h>
#include <...\Windows Kits\10\Include\10.0.10586.0\um\winhttp.h>
const LPCWSTR Agent = (wchar_t*)TEXT("User Agent");
const LPCWSTR Url = (wchar_t*)TEXT("www.google.com");
using namespace std;
int main()
{
// Declare Variables:
DWORD dwSize = 0;
DWORD dwDownloaded = 0;
LPSTR pszOutBuffer;
BOOL bResults = FALSE;
HINTERNET hSession = NULL,
hConnect = NULL,
hRequest = NULL;
// Use WinHttpOpen to obtain a session handle:
hSession = WinHttpOpen(Agent,
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS, 0 );
// Specify an HTTP server.
if( hSession )
hConnect = WinHttpConnect( hSession, Url, INTERNET_DEFAULT_HTTPS_PORT, 0 );
// Create an HTTP request handle.
if( hConnect )
hRequest = WinHttpOpenRequest(hConnect, L"GET", NULL,
NULL, WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_SECURE );
/*
* <INCOMPLETE>
*/
// Terminate Process Successfully:
return EXIT_SUCCESS;
}
(注意:“... \ Windows Kits \”是我的Windows SDK副本的路径)
然后我继续将我的程序链接到“winHTTP.lib”库。
在“... \ Windows Kits \ 10 \ Include \ 10.0.10586.0 \ um \ winhttp.h”中: 致命错误:winapifamily.h:没有这样的文件或目录
似乎无论出于何种原因,我的编译器都找不到这个“winapifamily.h”。
这是编译器,Windows SDK的问题,还是我的代码中出错?
我该如何解决这个问题?我是否需要安装 winHTTP Library 的另一个副本,还是有更简单的方法来解决问题?