指定一个HTTP请求的初始目标服务器并返回一个指向初始服务器的HTTP会话连接句柄.
#Include <WinHttp.au3>
_WinHttpConnect($hSession, $sServerName [, $iServerPort = Default ])
$hSession | 由以前调用 WinHttpOpen 函数返回的有效的 WinHTTP 会话句柄. |
$sServerName | HTTP 服务器的主机名. |
$iServerPort | [可选参数] 指定建立连接的服务器上的TCP/IP端口 (默认为 $INTERNET_DEFAULT_PORT) |
成功: | 返回一个指向HTTP会话的有效连接句柄. |
失败: | 返回 0 并设置 @error: |
1 - DllCall 失败 |
#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.pravda.ru")
If @error Then
MsgBox(48, "Error", "Error getting connection handle." & @CRLF & "Error number is " & @error)
Else
ConsoleWrite("+ Connection handle $hConnect = " & $hConnect & @CRLF)
MsgBox(64, "Yes!", "Handle is get! $hConnect = " & $hConnect)
EndIf
; 关闭句柄
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)