Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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 = &H20Private 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 LongPrivate 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 LongPrivate 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 LoadResConstantsPrivate 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.dllHelp, please?

I have looked at it and everything looks fine, except possibly the function declaration.
Try this version. It is slightly different than yours. Yours has no Alias.
Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
Stuart

StuartS!
You're the man :)
That solved my problem perfectly. I suppose I should have asked for help a week ago. I've been at it for to long on my own and have tried approximately 20 different versions of the same thing to no avail.
Thank you for the quick response. This forum is great!
- Greg Apel -

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |