通常我们会像下面一样调用:
HINTERNET HttpOpenRequestA(
[in] HINTERNET hConnect,
[in] LPCSTR lpszVerb,
[in] LPCSTR lpszObjectName,
[in] LPCSTR lpszVersion,
[in] LPCSTR lpszReferrer,
[in] LPCSTR *lplpszAcceptTypes,
[in] DWORD dwFlags,
[in] DWORD_PTR dwContext
);
CONST TCHAR *szAcceptType=__HTTP_ACCEPT_TYPE;
hRequest = HttpOpenRequest( hConnection,
__HTTP_VERB_GET, // HTTP Verb
szURI, // Object Name
HTTP_VERSION, // Version
NULL, // Reference
&szAcceptType, // Accept Type
INTERNET_FLAG_KEEP_CONNECTION | NTERNET_FLAG_NO_CACHE_WRITE,
0); // context call-back point
这里将会存在隐患,不定时随机崩溃
First-chance exception in Test.exe (KERNEL32.DLL): 0xC0000005: Access Violation
这里需要查阅MSDN后就能明白了:
HttpOpenRequestA 函数 (wininet.h) - Win32 apps | Microsoft Learn
所以要按上面的方法写szAcceptTypes,因为他是一个二维数组.