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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internet Connection; how can it be checked in VB6 3

Status
Not open for further replies.

chequi

IS-IT--Management
Apr 24, 2000
24
0
0
PR
Please, I need to know how to check in VB6 if the internet connection is active; and in the case it is not; prompt the default connection to make the dial up.

Thanks a lot.


 
To see if you are connected to the internet do something like:
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpSFlags As Long, ByVal dwReserved As Long) As Long
Private Function ConnectedToInternet() As Boolean
ConnectedToInternet = InternetGetConnectedState(0&, 0&)
End Function

Private Sub Command1_Click()
MsgBox ConnectedToInternet
End Sub
 
And here it is modified to prompt to connect

Option Explicit
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpSFlags As Long, ByVal dwReserved As Long) As Long
Private Declare Function InternetAutodial Lib "wininet.dll" (ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Const INTERNET_AUTODIAL_FORCE_ONLINE = 1
Private Function ConnectedToInternet() As Boolean
ConnectedToInternet = InternetGetConnectedState(0&, 0&)
End Function
Private Sub Command1_Click()
If ConnectedToInternet = False Then
InternetAutodial INTERNET_AUTODIAL_FORCE_ONLINE, 0
End If
End Sub
 
Thanks DrJavaJoe. I will give it a try right away. I will let you know about the result.
 
Hi DrJavaJoe:

It worked perfectly. Exactly what I was looking for. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top