无法在VBA中使用“ wininet.dll”进行连接

问题描述 投票:0回答:1

我正在使用下面的代码段通过VBA中的“ wininet.dll”连接到服务器,但无法连接到该服务器。但是,当我尝试使用WinScp 5.15.1.0版本连接到服务器时,它就可以连接;当我尝试使用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
vba excel-vba ftp winscp wininet
1个回答
0
投票

如果您在WinSCP中得到“无法同意密钥交换算法”]],则表示您正在使用SFTP协议,而不是FTP。 Wininet speaks

© www.soinside.com 2019 - 2024. All rights reserved.