;===============================================================================
;
; Function Name: _FTPPutFile()
; Description: Puts an file on an FTP server.
; Parameter(s): $l_FTPSession - The Long from _FTPConnect()
; $s_LocalFile - The local file.
; $s_RemoteFile - The remote Location for the file.
; $l_Flags - Special flags.
; $l_Context - I dont got a clue what this does.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Wouter van Kesteren
;
;===============================================================================
Func _FTPPutFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0)
Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpPutFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context)
If @error OR $ai_FTPPutFile[0] = 0 Then
SetError(-1)
Return 0
EndIf
Return $ai_FTPPutFile[0]
EndFunc ;==> _FTPPutFile()
;===============================================================================
;
; Function Name: _FTPPutFile()
; Description: Puts an file on an FTP server.
; Parameter(s): $l_FTPSession - The Long from _FTPConnect()
; $s_LocalFile - The local file.
; $s_RemoteFile - The remote Location for the file.
; $l_Flags - Special flags.
; $l_Context - I dont got a clue what this does.
; Requirement(s): DllCall, wininet.dll
; Return Value(s): On Success - 1
; On Failure - 0
; Author(s): Wouter van Kesteren
;
;===============================================================================
Func _FTPGetFile($l_FTPSession, $s_RemoteFile, $s_LocalFile, $s_Disabled = False, $s_FlagsAndAttributes = 0, $l_Flags = 0, $l_Context = 0)
Local $ai_FTPGetFile = DllCall('wininet.dll', 'int', 'FtpGetFile', 'long', $l_FTPSession, 'str', $s_RemoteFile, 'str', $s_LocalFile, "int", $s_Disabled , 'long', $l_Flags, 'long', $l_Context)
If @error OR $ai_FTPGetFile[0] = 0 Then
SetError(-1)
Return 0
EndIf
Return $ai_FTPGetFile[0]
EndFunc ;==> _FTPGetFile()
;模仿_ftpputfile写的一个_ftpgetfile函数;
;参照了微软官方的msdn函数库
;msdn 查询方法为: msdn 函数名 通过g.cn搜索,可一次性找到所对应函数,在函数下方有函数所必需的dll文件的说明
;autoit脚本中没有bool变量
;$s_disabled在msdn中应该是BOOL fFailIfExists 参见FtpGetFile Function,在autoit v3中的表达方法如上,"int",$s_Disabled,用整型变量来表达了布尔变量值
;在参数声明的地方直接赋值,即可实现默认赋值方法
#include <FTP.au3>
$server = '127.0.0.1'
$username = ''
$pass = ''
$remoteFile = '/传输软件打包0904/Auto1hour(win2000).rar'
$localFile = 'D:/Lbghost/Auto1hour(win2000).rar'
$Open = _FTPOpen('MyFTP Control')
$Conn = _FTPConnect($Open, $server, $username, $pass)
If $Conn == 0 Then
MsgBox(4096,"Wrong Test!","Can not open the FTP!",10)
Exit
Else
ToolTip(@CRLF & " 已经连接到FTP:" & $server & " " & @CRLF, 800, 700, "", 1)
Sleep(10000)
EndIf
$Ftpp = _FtpGetFile($Conn, $remoteFile, $localFile)
If $Ftpp == 0 Then
MsgBox(4096,"Wrong Test!","There is an error occur!",10)
Else
MsgBox(4096,"congratulate!","Your FTP Copy is successful!!!",10)
EndIf
$Ftpc = _FTPClose($Open)
Exit