--bennykgd,
你的程序好像是来检测Internet连接状态的,好像不合楼主要求的“内网”
如下是我的测试代码,非常简陋,不过能够达到目的
废话:想不到Indy控件使用起来如此方便简单,呵呵,真是让人欣赏这高手所著的程序,同时也当然很感谢高手所作的系列Indy控件.
{*
如下代码使用Ping来维护内网的计算机列表
Win Xp +Delphi2005测试通过
2005-4-24凌晨
}
unit Unit1;
...
type
TForm1 = class(TForm)
ListBox1: TListBox;
Timer1: TTimer;
IdIcmpClient1: TIdIcmpClient;
procedure FormDblClick(Sender: TObject);
procedure IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
procedure Timer1Timer(Sender: TObject);
...
var
Form1: TForm1;
implementation
{$R *.dfm}
const
ipHead :string ='192.168.0.';
procedure TForm1.Timer1Timer(Sender: TObject);
var
i:Integer;
begin
ListBox1.Clear;
IdIcmpClient1.ReceiveTimeout :=1000;
for i:=1 to 255 do
begin
IdIcmpClient1.Host :=ipHead +IntToStr(i);
[red]IdIcmpClient1.Ping;[/red]
Application.ProcessMessages;
end;
end;
procedure TForm1.IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
var
sTime :string;
begin
Caption :=IdIcmpClient1.Host;
if [red][black]AReplyStatus.ReplyStatusType=rsEcho[/black][/red] then
begin
ListBox1.Items.Add(AReplyStatus.FromIpAddress);
end;
end;
procedure TForm1.FormDblClick(Sender: TObject);
var
i:Integer;
begin//仅仅为了自己测试
ListBox1.Clear;
IdIcmpClient1.ReceiveTimeout :=100;
for i:=1 to 255 do
begin
IdIcmpClient1.Host :=ipHead +IntToStr(i);
IdIcmpClient1.Ping;
Application.ProcessMessages;
end;
end;
end.