大家进来给点思路、谢谢!
在弄QTP连接FTP的测试。没做出来。。。SystemUtil.Run "ftp://ftp:ftp@192.168.0.2/test.txt"如果这样的话就直接调用IE把test.txt文件显示出来了。。。而不是调用本机的notepad.exe这个程序来打开了?
如果要调用本地的notepad.exe这个程序来打开。是不是要先通过QTP连接FTP服务器将文件下载到本机再打开呢?
那位有做过这个的、解答一下啊。谢谢! 先下载,再调用Notepad打开
可利用wininet.dll的相关函数来实现:
Const DEFAULT_FTP_PORT =21
Const SERVICE_FTP = 1
Const OPEN_TYPE_DIRECT = 1
Const FTP_TRANSFER_TYPE_ASCII = 1
Extern.Declare micLong,"InternetOpen","wininet.dll","InternetOpenA",micString,micDWord,micString,micString,micDWord
Extern.Declare micLong,"InternetConnect","wininet.dll","InternetConnectA",micLong,micString,micInteger,micString,micString,micDWord,micDWord,micDWord
Extern.Declare micInteger,"FtpGetFile","wininet.dll","FtpGetFileA",micLong,micString,micString,micInteger,micDWord,micDWord,micDWord
Extern.Declare micInteger,"FtpPutFile","wininet.dll","FtpPutFileA",micLong,micString,micString,micDWord
Extern.Declare micInteger,"InternetCloseHandle","wininet.dll","InternetCloseHandle",micLong
'打开
hInternet = Extern.InternetOpen("QTP_FTP",OPEN_TYPE_DIRECT,vbNullChar,vbNullChar,0)
If hInternet=0 Then Print("QTP_FTP:Failed to setup FTP environment.")
' 连接
hConnection = Extern.InternetConnect(hInternet,"www.atstudy.com",DEFAULT_FTP_PORT,"user1","user1",1,0,0)
If hConnection =0 Then Print("Failed to setup FTP environment")
' 上传
' bRetval = Extern.FtpPutFile(hConnection,sLocalFile,sRemoteFile,0)
' 下载
bRetval = Extern.FtpGetFile(hConnection,"/Mercury/QuickTest/QTP crack.rar","D:\QTP crack.rar",0,0,1,0)
If Not CBool(bRetVal) Then
Reporter.ReportEvent micFail,"FTP:FtpGetFile function","Failed to open download file."
else
Print("FTP:File :QTP crack.rar downloaded successfully")
'Reporter.ReportEvent micPass,"FTP:FtpPutFile function","FTP:File"&sLocalFile&"upload successfully."
End If
' 关闭
Extern.InternetCloseHandle(hConnection)
Extern.InternetCloseHandle(hInternet)
回复 2# 的帖子
不错,赞个! 谢谢、我去试试看。
页:
[1]