Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.433 Beiträge
 
Delphi 7 Professional
 
#12

AW: Abfrage des win32_pingstatus per WMI schlägt "plötzlich" fehl

  Alt 12. Dez 2017, 14:19
Würden die Indy-Komponenten bei Crossplattform funktionieren?

Wenn ja:
Komponente TIdIcmpClient.
Dem Ereignis OnReply eine Routine zuweisen.
Delphi-Quellcode:
// Auf dem Formular
    Ping: TIdIcmpClient;

// Buttonclick oder so:
Ping.Host := 'IP oder Rechnername';
Try
  Ping.Ping;
Except
  on e : Exception do begin
    // Naja, Fehlerbehandlung ...
  end;
end;

// Ereignisroutine:
procedure TForm1.PingReply(ASender: TComponent; const AReplyStatus: TReplyStatus);
begin
  if AReplyStatus.FromIpAddress = '0.0.0.0then exit;
  // AReplyStatus auswerten:
  // z. B.:
  ShowMessage(Format('%s - %s - Replay: %s - %d ms', [
    Ping.Host,
    AReplyStatus.FromIpAddress,
    AReplyStatus.Msg,
    AReplyStatus.MsRoundTripTime
  ]));
end;
  Mit Zitat antworten Zitat