Function Reference


InetGetInfo

Returns detailed data for a handle returned from InetGet().

InetGetInfo ( [handle [, index = -1]] )

Parameters

handle [optional] A handle return from InetGet().
index [optional] The index for the data to retrieve. If this value is -1 an array containing all of the below data will be returned.
    $INET_DOWNLOADREAD (0) - Bytes read so far (this is updated while the download progresses).
    $INET_DOWNLOADSIZE (1) - The size of the download in bytes (this may not always be present).
    $INET_DOWNLOADCOMPLETE (2) - Set to True if the download is complete, False if the download is still ongoing.
    $INET_DOWNLOADSUCCESS (3) - True if the download was successful. If this is False then the next data member will be non-zero.
    $INET_DOWNLOADERROR (4) - The error value for the download. The value itself is arbitrary. Testing that the value is non-zero is sufficient for determining if an error occurred.
    $INET_DOWNLOADEXTENDED (5) - The extended value for the download. The value is arbitrary and is primarily only useful to the AutoIt developers.

Constants are defined in InetConstants.au3.

Return Value

Success: the request data.
Failure: an empty string and sets the @error flag to non-zero.

Remarks

If called with no arguments then the total number of active downloads will be returned.

This function can be called in a loop to query the number of bytes download or to pause until a download is complete.

Related

InetGet

Example

#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