Hello, I am new to this forum. This is my first post, yet it is an ugly problem I am having.
I am attempting to use the wininet.dll API to download a file from my ftp server for use in a Visual Basic 6.0 application. Just about every website I visit has some sort of tutorial saying how "easy" it is to call these functions, but it is escaping me.
Here is my code - and I appreciate any assistance offered:
Option Explicit
'******* START DECLARATIONS FOR WININET.DLL FTP CONNECTION *******
Const scUserAgent = "vb wininet"
Const INTERNET_SERVICE_FTP = 1
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_FLAG_PASSIVE = &H8000000
Const FTP_TRANSFER_TYPE_BINARY = 0
Const FILE_ATTRIBUTE_ARCHIVE = &H20
Private Declare Function InternetOpen _
Lib "wininet.dll" Alias "InternetOpenA" ( _
ByVal sAgent As String, _
ByVal lAccessType As Long, _
ByVal sProxyName As String, _
ByVal sProxyBypass As String, _
ByVal lFlags As Long) As Long
Private Declare Function InternetConnect _
Lib "wininet.dll" Alias "InternetConnectA" ( _
ByVal hInternetSession As Long, _
ByVal sServerName As String, _
ByVal nServerPort As Integer, _
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 FtpGetFile _
Lib "wininet.dll" ( _
ByVal hConnect As Long, _
ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, _
ByVal fFileExists As Long, _
ByVal dwFlagsAndAttributes As Long, _
ByVal dwFlags As Long, _
ByVal dwContext As Long) As LoadResConstants
Private Declare Function InternetCloseHandle _
Lib "wininet.dll" (ByVal hInet As Long) As Integer
'******* END DECLARATIONS FOR WININET.DLL FTP CONNECTION *******
Private Sub Command1_Click()
'handles for connection
Dim hOpen&, hConn&
'long for return values
Dim lRes As Long
hOpen = InternetOpen(scUserAgent, _ INTERNET_OPEN_TYPE_DIRECT, _
vbNullString, vbNullString, 0)
hConn = InternetConnect(hOpen, _ "ftp.my_site.com", "21", _
"my_username", "my_password", _
INTERNET_SERVICE_FTP, _
INTERNET_FLAG_PASSIVE, 0)
lRes = FtpGetFile(hConn, _
"some_file.zip", "C:\some_file.zip", _
False, FILE_ATTRIBUTE_ARCHIVE, _
FTP_TRANSFER_TYPE_BINARY, 0&)
'yep, closes connection
InternetCloseHandle hConn
InternetCloseHandle hOpen
End Sub
'************ END OF PROGRAM *************
Okay, that's pretty much it. A form, a command button called Command1, and the code therein.
When I click on the command button, I see network activity on my monitor, but then after a few seconds, I receive this error:
Can't find DLL entry point FTPGetFile in wininet.dll
Help, please?