I'm using below code snippet to connect to a server using wininet.dll
in VBA but not able to connect to that. But when I try to connect to the server using WinSCP 5.15.1, it's able to connect. And when I try to use 5.5.5.0 version of WinSCP, it shows error "Couldn't agree a key exchange algorithm".
It also shows login error when I try to connect it using ftp
command in cmd
.
I'm wondering is it possible to connect to the server using wininet.dll
in VBA by fixing any thing.
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