uses
Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
StdCtrls, Ping, ExtCtrls;
type
TForm1 = class(TForm)
Ping1: TPing;
Button1: TButton;
procedure Ping1EchoReply(Sender, Icmp: TObject; Error: Integer);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Idx1, Idx2 : Integer;
ThereArray : Array[0..255, 0..255] of Boolean;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
I, J : Integer;
begin
FillChar(ThereArray, Sizeof(ThereArray), False); // Assume none????
For I := 0 to 255 Do
For J := 0 to 255 Do
Begin
Idx1 := I;
Idx2 := J;
// The following statement really shouldn't be here
// because ThereArray was just cleared OR don't clear
// at the top of buttonclick
If (ThereArray[I, J] = True) Then
Continue; // Skip it if it's there already???? Mutually exclusive with FillChar above
Ping1.Address := '192.168.'+IntToStr(I)+'.'+IntToStr(J);
Ping1.Ping;
End;
end;
procedure TForm1.Ping1EchoReply(Sender, Icmp: TObject; Error : Integer);
begin
if (Error <> 0) then
ThereArray[Idx1, Idx2] := True
else
ThereArray[Idx1, Idx2] := False;
End;
Begin
// Unit init
FillChar(ThereArray, SizeOf(ThereArray), False); //Alt clearing
end.