Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help Quick FTP Question

Status
Not open for further replies.

pink2070

Programmer
Jan 29, 2004
23
US
Someone....PLEASE....HELP....

I'm working with wininet.dll functions. My goal is to simply download a file from an ftp site using these functions

Here are declarations for the wininet.dll functions, these functions are declared at the class level (class level being the level of the form)
**********************************************************
'This is the internet open function
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

'This is the internet connect function
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

'This file is used to retrieve files
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
**********************************************************


Then I create a button that fires those functions after I have defined them
**********************************************************
Dim lngINet As Long
Dim lngINetConn As Long
Dim blnrc As Boolean
Dim strErr As String

Try
lngINet = InternetOpen("FileTransfer", 1, vbNullString, vbNullString, 0)

lngINetConn = InternetConnect(lngINet, "ftp.microsoft.com", 0, _
vbNullString, vbNullString, 1, 0, 0)

blnrc = FtpGetFile(lngINetConn, "index.html", "c:\dirmap.txt", False, 0, 1, 0)
Catch err As Exception
strErr = err.Message
End Try
**********************************************************


It is my belief that my code breaks down at the InternetConnect function even though the FtpGetFile returns a false (False meaning the function did not fire), I believe it is returning a false because the first parameter is returning a bad value.

Please help

Pink
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top