Check if active internet connection

Asked

Viewed 461 times

0

Is there any function that returns if there is an active internet connection? I mean, not only the connected network card, but yes, an active connection effectively.

Vlw.

2 answers

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 
  • is indicating error: Bad DLL Calling convertion in this line: Myping = (Ping(IP, pNumCalls, 15, lTime) = 1): End Function

  • ok. got it. I found it easier by INET. I already use it for other purposes in the application. thanks

0


It is that this solution is called API and depends on specific Dlls. Another solution is to use the INET component and encode like this:

Wresposta = Inet1.OpenURL("http://www.brasil.gov.br/")
if Wresposta = "" then
   msgbox("Fora da NET")
endif

Browser other questions tagged

You are not signed in. Login or sign up in order to post.