Function Reference


_FTP_SetStatusCallback

Registers callback function that WinINet functions can call as progress is made during an operation

#include <FTPEx.au3>
_FTP_SetStatusCallback ( $hInternetSession, $sFunctionName )

Parameters

$hInternetSession as returned by _FTP_Open()
$sFunctionName the name of the User Defined Function to call.

Return Value

Success: a pointer to callback function.
Failure: 0 and sets the @error flag to non-zero.

Remarks

The callback function is called with the following parameters (see InternetStatusCallback Windows API):
$hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength

Related

_FTP_Command, _FTP_Connect, _FTP_DecodeInternetStatus, _FTP_DirPutContents, _FTP_FileGet, _FTP_FileOpen, _FTP_FilePut, _FTP_FindFileFirst, _FTP_ListToArray, _FTP_ListToArray2D, _FTP_ListToArrayEx, _FTP_Open

See Also

Search InternetSetStatusCallback in MSDN Library.

Example

#include <Debug.au3>
#include <FTPEx.au3>
#include <WinAPIHOBj.au3>
#include <WinAPIMem.au3>

_DebugSetup(StringTrimRight(@ScriptName, StringLen(".exe")) & ' example', True)

;~ Local $sServer = 'ftp.cs.brown.edu' ; Brown Computer Science
Local $sServer = 'speedtest.tele2.net' ; Tele2 Speedtest Service
Local $sUsername = ''
Local $sPass = ''

Local $hOpen = _FTP_Open('MyFTP Control')
Local $pCallback = _FTP_SetStatusCallback($hOpen, 'FTPStatusCallbackHandler')

Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass, 0, $INTERNET_DEFAULT_FTP_PORT, $INTERNET_SERVICE_FTP, 0, $pCallback)

Local $iFtpc = _FTP_Close($hConn)
Local $iFtpo = _FTP_Close($hOpen)

Func FTPStatusCallbackHandler($hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength)
        #forceref $hInternet, $iContext
        If $iInternetStatus = $INTERNET_STATUS_REQUEST_SENT Or $iInternetStatus = $INTERNET_STATUS_RESPONSE_RECEIVED Then
                Local $iBytesRead
                Local $tStatus = DllStructCreate('dword')
                _WinAPI_ReadProcessMemory(_WinAPI_GetCurrentProcess(), $pStatusInformation, $tStatus, $iStatusInformationLength, $iBytesRead)
                _DebugOut(_FTP_DecodeInternetStatus($iInternetStatus) & ' | Size = ' & DllStructGetData($tStatus, 1) & ' Bytes    Bytes read = ' & $iBytesRead)
        Else
                _DebugOut(_FTP_DecodeInternetStatus($iInternetStatus))
        EndIf
EndFunc   ;==>FTPStatusCallbackHandler