1 (edited by livexox 2018-02-06 21:02:04)

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;

Re: Ping and PingEx

Run your project with administrator privileges.
https://www.sevenforums.com/attachments/tutorials/12831d1243933304-run-administrator-context_menu.jpg

Dmitry.

Re: Ping and PingEx

Hello Dmitry and all MVD fans

Even in the presence of internet access it takes a multiple clicks for

ping('google.com')

to respond. Is there a way to address this situation or better still another option.

In advance, I thank you for your assistance.

Re: Ping and PingEx

humblelion wrote:

Hello Dmitry and all MVD fans

Even in the presence of internet access it takes a multiple clicks for

ping('google.com')

to respond. Is there a way to address this situation or better still another option.

In advance, I thank you for your assistance.

I'm also facing the same problem. Even in the presence of internet, it takes a lot of clicks for

ping('google.com')

to take effect. How I wish there was an alternative method or a better way of writing this code.