函数参考


_WinHttpQueryDataAvailable

返回是否可由_WinHttpReadData()读取数据.

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

参数

$hRequest handle returned by _WinHttpOpenRequest().

返回值

成功: 如果数据可用时返回1.
可用 @extended 返回可用字节数量
失败: 返回 0 并设置 @error:
1- DllCall 失败

注意/说明

必须对此句柄完成 _WinHttpReceiveResponse() 函数调用后再调用 _WinHttpQueryDataAvailable.

相关

_WinHttpOpenRequest, _WinHttpReadData, _WinHttpReceiveResponse

详情参考

http://msdn.microsoft.com/en-us/library/aa384101(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, "google.com")
; 指明请求
Global $hRequest = _WinHttpOpenRequest($hConnect)
; 发送请求
_WinHttpSendRequest($hRequest)

; 等待响应
_WinHttpReceiveResponse($hRequest)

; 检查数据是否有效...
If _WinHttpQueryDataAvailable($hRequest) Then
    MsgBox(64, "OK", "Data from google.com is available!")
Else
    MsgBox(48, "Error", "Site is experiencing problems (or you).")
EndIf

; 清理
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)