函数参考


_WinHttpReceiveResponse

等待接收由 WinHttpSendRequest() 函数初始化的HTTP请求的响应.

#Include <WinHttp.au3>
_WinHttpReceiveResponse($hRequest)

参数

$hRequest 由 _WinHttpOpenRequest() 返回的句柄和由 _WinHttpSendRequest() 发送请求后的句柄.

返回值

成功: 返回 1.
失败: 返回 0 并设置 @error:
1 - DllCall 失败

注意/说明

在调用 _WinHttpReceiveResponse() 函数前,必须等待 _WinHttpQueryDataAvailable() 和 _WinHttpReadData() 函数调用完成.

相关

_WinHttpOpenRequest, _WinHttpSetTimeouts

详情参考

http://msdn.microsoft.com/en-us/library/aa384105(VS.85).aspx

示例/演示


#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6

#include "WinHttp.au3"

Opt("MustDeclareVars", 1)

; 初始化
Global $hOpen = _WinHttpOpen()
; 指明连接到哪里
Global $hConnect = _WinHttpConnect($hOpen, "en.wikipedia.org")
; 创建请求
Global $hRequest = _WinHttpOpenRequest($hConnect, -1, "wiki/Manchester_United_F.C.")
; 发送它
_WinHttpSendRequest($hRequest)

; 等待响应
_WinHttpReceiveResponse($hRequest)
If @error Then
    MsgBox(48, "Error", "Error ocurred for WinHttpReceiveResponse, Error number is " & @error)
Else
    MsgBox(64, "All right!", "Server at 'en.wikipedia.org' processed the request.")
EndIf

; 关闭句柄
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)