habs nun mit VB5 ausprobiert und funkt. tadellos
Code:
Option Explicit
' Benötigte API-Deklaration
Private Declare Function IsDestinationReachable Lib _
"Sensapi.dll" Alias "IsDestinationReachableA" _
(ByVal lpszDestination As String, _
lpQOCInfo As QOCINFO) As Long
Private Type QOCINFO
dwSize As Long
dwFlags As Long
dwInSpeed As Long
dwOutSpeed As Long
End Type
' Server anpingen und Reaktionszeit zurückgeben
Public Function Ping(ByVal sHost As String) As Single
Dim QI As QOCINFO
Dim vTime As Single
QI.dwSize = Len(QI)
vTime = Timer
If IsDestinationReachable(sHost, QI) = 1 Then
Ping = Timer - vTime
Else
Ping = -1
End If
End Function
Private Sub Form_Load()
Dim nTime As Single
nTime = Ping("217.160.105.222")
If nTime <> -1 Then
MsgBox "Server erreichbar: Pingzeit: " & CStr(nTime) & " Sekunden"
Else
MsgBox "Server nicht erreichbar!"
End If
End Sub