【发布时间】:2020-07-27 11:13:48
【问题描述】:
我正在使用下面的代码 sn-p 在 VBA 中使用wininet.dll 连接到服务器,但无法连接到该服务器。但是当我尝试使用 WinSCP 5.15.1 连接到服务器时,它能够连接。当我尝试使用 5.5.5.0 版本的 WinSCP 时,它显示错误 “无法同意密钥交换算法”。
当我尝试在cmd 中使用ftp 命令连接它时,它也会显示登录错误。
我想知道是否可以通过修复任何东西在 VBA 中使用wininet.dll 连接到服务器。
Public Function checkFTPpath(ByVal ServerName, ByVal Username, ByVal password, ByVal remote_path) As Boolean
Dim hostFile As String
Dim INet As Long
Dim INetConn As Long
Dim RetVal As Long
Dim Success As Boolean
Success = False
RetVal = False
INet = InternetOpen("MyFTP Control", 1&, vbNullString, vbNullString, 0&)
If INet > 0 Then
INetConn = InternetConnect(INet, ServerName, 21, Username, password, 1&, 0&, 0&)
If INetConn > 0 Then
Success = FtpSetCurrentDirectory(INetConn, "/")
Success = FtpSetCurrentDirectory(INetConn, remote_path)
RetVal = InternetCloseHandle(INetConn)
End If
RetVal = InternetCloseHandle(INet)
End If
checkFTPpath = Success
End Function
【问题讨论】:
标签: excel vba ftp winscp wininet