窗体上放置一个TIdIcmpClient控件,uses MMSystem单元
procedure TForm1.Button1Click(Sender: TObject);
begin
IdIcmpClient1.Host:='192.168.1.50';
IdIcmpClient1.ReceiveTimeout:=1000;
IdIcmpClient1.Ping;
end;
procedure TForm1.IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
begin
if AReplyStatus.BytesReceived<=0 then
PlaySound(Pchar('c:/test.wav'),0,SND_ASYNC);
end;