Hi there,
I am building an application that uses wininet ftp calls, all of which are working fine except from my request for the current directory. The following is my (cut down) code...
Please help!
Pete
I am building an application that uses wininet ftp calls, all of which are working fine except from my request for the current directory. The following is my (cut down) code...
Code:
Option Explicit
Private Const MAX_PATH = 260
Private Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Private Const INTERNET_DEFAULT_FTP_PORT = 21
Private Const INTERNET_SERVICE_FTP = 1
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal lpszAgent As String, ByVal dwAccessType As Long, ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, ByVal dwFlags As Long) As Long
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Long, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Long
Private Declare Function FtpGetCurrentDirectory Lib "WinInet" Alias "FtpGetCurrentDirectoryA" (ByVal hFtp As Long, lpszDirectory As String, ByVal BuffLength As Long) As Long
Private hConnect As Long
Private hFtp As Long
Public Sub Connect(Server As String, User As String, pwd As String)
hConnect = InternetOpen("Microsoft Excel", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
hFtp = InternetConnect(hConnect, Server, INTERNET_DEFAULT_FTP_PORT, User, pwd, INTERNET_SERVICE_FTP, 0, 0)
End Sub
Public Sub Disconnect()
If hConnect <> 0 Then
InternetCloseHandle hConnect
End If
End Sub
Public Function CurrentDir() As String
Dim RetVal As String * MAX_PATH
FtpGetCurrentDirectory hFtp, RetVal, Len(RetVal)
CurrentDir = Trim(RetVal)
End Function
Public Function CurrentDir() As String
Dim RetVal As String * MAX_PATH
FtpGetCurrentDirectory hFtp, RetVal, Len(RetVal)
CurrentDir = Trim(RetVal)
End Function
Please help!
Pete
Last edited by a moderator: