Einzelnen Beitrag anzeigen
Alt 02.12.2003, 22:19   #5
daytrader
Inventar
 
Benutzerbild von daytrader
 
Registriert seit: 30.01.2001
Alter: 52
Beiträge: 1.726


Standard

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
____________________________________


http://daytrader.soup.io/
daytrader ist offline   Mit Zitat antworten