Check if internet connection is active

0

Is there a function that returns if there is an active internet connection? I say, not only the network card connected, but an active connection.

Vlw.

    
asked by anonymous 08.11.2018 / 17:21

2 answers

0

This solution is with API call and depends on specific DLLs. Another solution is to use the INET component and code like this:

Wresposta = Inet1.OpenURL("http://www.brasil.gov.br/")
if Wresposta = "" then
   msgbox("Fora da NET")
endif
    
08.11.2018 / 18:20
0
Private Declare Function Ping Lib "iphlpapi" _
Alias "#65" (ByVal pInternetProtocol As Long, pNumberOfCalls As Long, _
ByVal pMaxNumberOfCalls As Long, lTime As Long) As Long
Private Declare Function ConvertStringToIP Lib "wsock32" _
Alias "#10" (ByVal stoip As String) As Long

Function MyPing(sIPAddr As String) As Boolean
Dim IP As Long, pNumCalls As Long, lTime As Long
IP = ConvertStringToIP(sIPAddr)
MyPing = (Ping(IP, pNumCalls, 15, lTime) = 1): End Function

'Chamando a Função'
Private Sub Form_Load()
Dim Result As Boolean: Result = MyPing("200.158.24.129")
If Result = True Then
MsgBox "OK"
Else
MsgBox "Não Respondeu": End If
End Sub 
    
08.11.2018 / 17:34