Topic: Ping and PingEx
I want to be able to check if a host/computer is ON using the computer name or an IP address like 192.168.2.1..
I tried the code below I found in another post but it always fails. is there anything i'm missing. Please Advise.
Could you provide a sample project?
procedure Form1_Button6_OnClick (Sender: TObject; var Cancel: boolean);
begin
if Ping('google.com') then ShowMessage('Ok') else ShowMessage('Failed');
end;
procedure Form1_Button4_OnClick (Sender: TObject; var Cancel: boolean);
var
AvgMs: Double;
begin
if PingEx('192.168.2.1', 5, AvgMs) then
ShowMessage('Average ping: '+FloatToStr(AvgMs)+'ms')
else ShowMessage('Failed');
end;