函数参考


_FTP_SetStatusCallback

注册回调函数,WinInet 函数可以调用一项操作中的进度.

#Include <FTPEx.au3>
_FTP_SetStatusCallback ( $l_InternetSession, $sFunctionName)

参数

$l_InternetSession _FTP_Open() 返回的句柄
$sFunctionName 调用用户定义的函数名.

返回值

成功: 返回回调函数指针
失败: 返回 0, 并设置 @error 为非 0

注意/说明

回调函数可以调用下列参数 (参考 InternetStatusCallback Windows API):
$hInternet, $dwContent, $dwInternetStatus, $lpvStatusInformation, $dwStatusInformationLength

相关

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

详情参考

在MSDN中搜索


示例/演示


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

_DebugSetup(StringTrimRight(@ScriptName, 4) & ' example', True)

Local $server = 'ftp.mozilla.org'
Local $username = ''
Local $pass = ''

Local $Open = _FTP_Open('MyFTP Control')
Local $Callback = _FTP_SetStatusCallback($Open, 'FTPStatusCallbackHandler')

Local $Conn = _FTP_Connect($Open, $server, $username, $pass, 0, $INTERNET_DEFAULT_FTP_PORT, $INTERNET_SERVICE_FTP, 0, $Callback)

Local $Ftpc = _FTP_Close($Open)

Func FTPStatusCallbackHandler($hInternet, $dwContent, $dwInternetStatus, $lpvStatusInformation, $dwStatusInformationLength)
    #forceref $hInternet, $dwContent
    If $dwInternetStatus = $INTERNET_STATUS_REQUEST_SENT Or $dwInternetStatus = $INTERNET_STATUS_RESPONSE_RECEIVED Then
        Local $Size, $iBytesRead
        $Size = DllStructCreate('dword')
        _WinAPI_ReadProcessMemory(_WinAPI_GetCurrentProcess(), $lpvStatusInformation, DllStructGetPtr($Size), $dwStatusInformationLength, $iBytesRead)
        _DebugOut(_FTP_DecodeInternetStatus($dwInternetStatus) & ' | Size = ' & DllStructGetData($Size, 1) & ' Bytes    Bytes read = ' & $iBytesRead)
    Else
        _DebugOut(_FTP_DecodeInternetStatus($dwInternetStatus))
    EndIf
EndFunc   ;==>FTPStatusCallbackHandler