我需要使用wininet.dll
中的FTP命令功能发送一些FTP命令。我使用QUIT
命令时它正在工作。但是当我尝试使用例如LS
或DIR
时,我得到了响应0.
Private Declare Function FtpCommand Lib "wininet.dll" Alias "FtpCommandA" (ByVal hConnect As Long, ByVal fExpectResponse As Long, ByVal dwFlags As Long, ByVal lpszCommand As String, ByVal dwContext As Long, phFtpCommand As Long) As Long
Private Function test()
Dim Success As Long
Dim iRet As Integer
Dim lngInet As Long
Dim lngInetConn As Long
Dim sCommand As String
Dim test44 As Long
sCommand = "DIR"
Dim test5 As Long
Dim lError As Long
Dim strBuffer As String
Dim lBufferSize As Long
Dim retVal As Long
lngInet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0) 'Open connection with fpt
If lngInet = 0 Then
iRet = MsgBox("bad")
Else
lngInetConn = InternetConnect(lngInet, Server.Value, 0, _
User.Value, Pass.Value, 1, 0, 0) 'Connect to server
If lngInetConn > 0 Then
Login = True
blnRC = FtpCommand(lngInetConn, True, FTP_TRANSFER_TYPE_ASCII, sCommand, test44, test5)
retVal = InternetGetLastResponseInfo(lError, strBuffer, lBufferSize)
Else
Login = False
LoginError
End If
End If
InternetCloseHandle (lngInet) 'Close Ftp I thnik is not necessary
InternetCloseHandle (lngInetConn) 'Close Connection I thnik is not necessary
End Function
答案 0 :(得分:1)
DIR
或LS
命令。有LIST
命令(或MLSD
或NLST
)。无论如何,您无法使用FtpCommand
函数检索目录列表。它仅适用于简单的命令。列表(或文件传输)需要与FtpCommand
功能未提供的FTP客户端合作。