-
August 28th, 2008, 03:40 PM
#1
Problem with establishing FTP using InternetConnect
Hello,
I am having a problem using the InternetConnect API to establish an FTP connection. using getlasterror returns error 87 which is invalid parameter.
I am not sure which parameter is invalid. I do believe the internet handle i am passing it is valid. heres the code
m_hConnHandle = InternetConnect(m_hInetHandle, "172.21.1.2", 0, "", "", 1, 0, 0)
Dim i As Int32 = Err.LastDllError()
i is always = 87
I tried passing in 21 for the port but that does not help
any help would be appreciated.
-
August 29th, 2008, 12:47 AM
#2
Re: Problem with establishing FTP using InternetConnect
Welcome to the forums!
You're in luck As I've been doing a lot with FTP these days.
I've done this :
Code:
'''''''''''''''''''''''
' API declarations
<DllImport("wininet.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Function InternetConnect(ByVal hInternet As IntPtr, ByVal lpszServerName As String, ByVal nServerPort As Short, ByVal lpszUserName As String, ByVal lpszPassword As String, ByVal dwService As Integer, _
ByVal dwFlags As Integer, ByRef dwContext As Integer) As IntPtr
End Function
<DllImport("wininet.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Function InternetOpen(ByVal lpszAgent As String, ByVal dwAcessType As Integer, ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, ByVal dwFlags As Integer) As IntPtr
End Function
''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''
'API Constants
Public Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net
Public Const INTERNET_DEFAULT_FTP_PORT = 21 ' default for FTP servers
Public Const INTERNET_SERVICE_FTP = 1
'''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''
'In My frmLoad:
Dim hInternet As IntPtr = InternetOpen(Nothing, INTERNET_OPEN_TYPE_DIRECT, Nothing, Nothing, 0)
Dim hConnection As IntPtr = InternetConnect(hInternet, rServer, INTERNET_DEFAULT_FTP_PORT, rUser, rPass, INTERNET_SERVICE_FTP, 0, 0)
'''''''''''''''''''''''''''''
And it works fine for me, try it as well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|