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.
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
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.