InetGetInfo
获取 InetGet() 返回句柄的详细数据.
InetGetInfo ( [handle [, index = -1]] )
参数
handle
|
[可选] 由 InetGet() 返回的句柄
|
index
|
[可选] 检索数据的索引. 如果此值为 -1, 将返回包含以下数据的数组:
$INET_DOWNLOADREAD (0) - 当前为止读取的字节(随下载进度即时更新).
$INET_DOWNLOADSIZE (1) - 下载的字节大小(可能并不总是存在).
$INET_DOWNLOADCOMPLETE (2) - 下载完成为 True, 下载仍在进行中为 False.
$INET_DOWNLOADSUCCESS (3) - 下载成功为 True. 如果是 False, 则下一个数据元素将为非零.
$INET_DOWNLOADERROR (4) - 下载的错误值. 该值是任意的. 如果此值非零, 则足以确定发生了下载错误.
$INET_DOWNLOADEXTENDED (5) - 下载信息的扩展值. 该值是任意的, 仅对 AutoIt 开发者有用.
常量定义在 InetConstants.au3
|
返回值
成功:
|
返回请求的数据.
|
失败:
|
返回空串, 设置 @error 为非零值.
|
备注
如果不附带参数, 则返回当前下载的总数.
函数可以循环调用查询下载的字节数, 或暂停查询直至下载完成.
函数示例
#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
Example()
Func Example()
; Save the downloaded file to the temporary folder.
Local $sFilePath = _WinAPI_GetTempFileName(@TempDir)
; Download the file in the background with the selected option of 'force a reload from the remote site.'
Local $hDownload = InetGet("http://www.autoitscript.com/autoit3/files/beta/update.dat", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND)
; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True.
Do
Sleep(250)
Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
; Retrieve details about the download file.
Local $aData = InetGetInfo($hDownload)
If @error Then
FileDelete($sFilePath)
Return False ; If an error occurred then return from the function and delete the file.
EndIf
; Close the handle returned by InetGet.
InetClose($hDownload)
; Display details about the downloaded file.
MsgBox($MB_SYSTEMMODAL, "", "Bytes read: " & $aData[$INET_DOWNLOADREAD] & @CRLF & _
"Size: " & $aData[$INET_DOWNLOADSIZE] & @CRLF & _
"Complete: " & $aData[$INET_DOWNLOADCOMPLETE] & @CRLF & _
"successful: " & $aData[$INET_DOWNLOADSUCCESS] & @CRLF & _
"@error: " & $aData[$INET_DOWNLOADERROR] & @CRLF & _
"@extended: " & $aData[$INET_DOWNLOADEXTENDED] & @CRLF)
; Delete the file.
FileDelete($sFilePath)
EndFunc ;==>Example
----------------------------------------
该函数可以通过命令调用 exect
参见:
InetGet
exect=$var_h=InetGet('http://www.mozilla.org',@DesktopDir&'\mozilla.html',1,1)||Sleep(1000)||$var_a=InetGetInfo($var_h,-1)||_ViewValues($var_a)||InetClose($var_h) ;; 下载页面并提供信息
© Аверин Андрей для Total Commander Image Averin-And@yandex.ru
|