Imports System
Imports System.Runtime. InteropServices
Public Class DllImports
<DllImport("Win Inet.dll", _
EntryPoint:="In ternetOpen", _
CharSet:=CharSe t.Auto, ExactSpelling:= True)> _
Public Shared Function InternetOpen( _
ByVal lpszAgent As String, _
ByVal dwAccessType As Int32, _
ByVal lpszProxyName As String, _
ByVal lpszProxyBypass As String, _
ByVal dwFlags As Int32) As IntPtr
End Function
<DllImport("Win Inet.dll", _
EntryPoint:="In ternetConnect", _
CharSet:=CharSe t.Auto, ExactSpelling:= True)> _
Public Shared Function InternetConnect ( _
ByVal hInternet As IntPtr, _
ByVal lpszServerName As String, _
ByVal nServerPort As Int32, _
ByVal lpszUsername As String, _
ByVal lpszPassword As String, _
ByVal dwService As Int32, _
ByVal dwFlags As Int32, _
ByVal dwContext As IntPtr) As IntPtr
End Function
<DllImport("Win Inet.dll", _
EntryPoint:="In ternetCloseHand le", _
CharSet:=CharSe t.Auto, ExactSpelling:= True)> _
Public Shared Function InternetCloseHa ndle( _
ByVal hInternet As IntPtr) As Int32
End Function
<DllImport("Win Inet.dll", _
EntryPoint:="In ternetGetLastRe sponseInfo", _
CharSet:=CharSe t.Auto, ExactSpelling:= True)> _
Public Shared Function InternetGetLast ResponseInfo( _
ByRef lpdwError As Int32, _
ByVal lpszBuffer As System.Text.Str ingBuilder, _
ByRef lpdwBufferLengt h As Int32) As Int32
End Function
Public Shared Function CheckFtpLogin( _
ByVal FtpServerName As String, _
ByVal FtpUsername As String, _
ByVal FtpPassword As String) As Boolean
Dim InternetOpen, InternetConnect As IntPtr
Dim a As Int32 = 724 'whatever
Dim p As New IntPtr(a)
InternetOpen = DllImports.Inte rnetOpen( _
"Mozilla/4.0+(compatible ;+MSIE+6.0;+Win dows+NT+5.2;+.N ET+CLR+1.1.4322 )", _
0, _
Nothing, _
Nothing, _
0)
If IntPtr.op_Equal ity(InternetOpe n, IntPtr.Zero) Then
'InternetOpen failed.
'Call Marshal.GetLast Win32Error() for the errorcode
Return False
End If
InternetConnect = DllImports.Inte rnetConnect( _
InternetOpen, _
FtpServerName, _
21, _
FtpUsername, _
FtpPassword, _
1, _
&H8000000, _
p)
If IntPtr.op_Equal ity(InternetCon nect, IntPtr.Zero) Then
'InternetOpen failed.
'Call Marshal.GetLast Win32Error() for the errorcode
'Call InternetGetLast ResponseInfo to see the response
Dim lpdwError As Int32 = 0
Dim lpdwBufferLengt h As Int32 = 2048
Dim lpszBuffer As _
New System.Text.Str ingBuilder(lpdw BufferLength)
DllImports.Inte rnetGetLastResp onseInfo( _
lpdwError, lpszBuffer, lpdwBufferLengt h)
'Free the handle:
DllImports.Inte rnetCloseHandle (InternetOpen)
Return False
End If
' Everything OK
'Free the handles:
DllImports.Inte rnetCloseHandle (InternetOpen)
DllImports.Inte rnetCloseHandle (InternetConnec t)
Return True
End Function
End Class
"Daren Hawes" <da***@webdesig nmagic.com.au> wrote in message
news:#G******** ******@TK2MSFTN GP10.phx.gbl...
Hi Martin,
I am so sorry, but I have tried to convert to VB. I am a student, and
find convering some things from C# to VB, especially system DLL imports!
Is there anywhere you can point me for a VB version of both the class
and the ASP.NET page?
Thx Daren
In the meantime I will search around...
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!