函数参考


_WinHttpWriteData

写入请求数据到一个HTTP服务器.

#Include <WinHttp.au3>
_WinHttpWriteData($hRequest, $vData [, $iMode = Default ])

参数

$hRequest 由 _WinHttpSendRequest() 函数返回的有效句柄.
$vData 要写入的数据.
$iMode [可选参数] 整数方式定义的写入模式. 默认为 0 - 写入一个 ANSI 字符串.

返回值

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

注意/说明

$vData 变量是要进行写入的字符串或二进制数据.
$iMode 可为下列值:

       0 - 写入ANSI字符串

       1 - 写入二进制字符串

相关

_WinHttpSendRequest, _WinHttpReadData

详情参考

http://msdn.microsoft.com/en-us/library/aa384120(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, "www.snee.com")
; 指明请求
Global $hRequest = _WinHttpOpenRequest($hConnect, "POST", "xml/crud/posttest.cgi?sgs")

Global $sPostData = "Additional data to send"
; 发送请求
_WinHttpSendRequest($hRequest, Default, Default, StringLen($sPostData))

; 写入附加数据到发送中
_WinHttpWriteData($hRequest, $sPostData)

; 等待响应
_WinHttpReceiveResponse($hRequest)

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

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