Connecting to net

Darren66

Newcomer
Joined
Jun 9, 2003
Messages
20
I am a newbie to VB.net and have been reading manuals but would appreciate it if somebody could point me in the right direction.
I want to click a button and connect to the internet if not already connected - something which I achieved in VB6 with wininet.dll.

Is there a better way of doing this now in .net??
 
Or let me rephrase that : It seems to me that InternetConnect API Works in VB6 but not VB .NET
Any suggestions?
 
I ran this code through the upgrade wizard from VB6 to VB.net and this was the result. I noticed that the data types have been changed from Longs to Integers however I changed tried changing them back to Longs with no success.
The first piece of code is from my form and is the line which attempts to make the connection.

<code>
hConnection = InternetConnect(hOpen, "ftp.mysite.com", INTERNET_INVALID_PORT_NUMBER, "user", "password", INTERNET_SERVICE_FTP, dwSeman, 0)
</code>

<code>
Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _
(ByVal hInternetSession As Integer, ByVal sServerName As String, ByVal nServerPort As Short, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Integer, ByVal lFlags As Integer, ByVal lContext As Integer) As Integer

Public Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInet As Integer) As Integer

Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Integer, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Integer) As Integer
</code>
 
Divil
Typically I think I've just managaed to get it working although at this point I'm not quite sure how. I hope I haven't wasted your time.
Many Thanks.
 
Back
Top