unit Unit1;
inte易做图ce
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ImgList, Ping, ComCtrls, jpeg, ExtCtrls, WinSkinData;
type TForm1 = class(TForm) TreeView1: TTreeView; Ping1: TPing; ImageList1: TImageList; GroupBox1: TGroupBox; Label1: TLabel; Edit1: TEdit; Label2: TLabel; Edit2: TEdit; Edit3: TEdit; Label3: TLabel; Button1: TButton; Label4: TLabel; SkinData1: TSkinData; Image1: TImage; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private Function Ping(strip:string):Boolean; { Private declarations } public { Public declarations } end;
var Form1: TForm1; i:Integer;
implementation
{$R *.dfm} Function TForm1.Ping(strip:string):Boolean; Begin ping1.address:=Trim(strip); Ping1.ping; if ping1.ErrorCode=0 then begin ping:=True; end Else Begin ping:=False; i:=i+1; End; End;
procedure TForm1.Button1Click(Sender: TObject); Var h:Integer; treenode1,treenode2:TTreeNode; begin //清空所有Item; TreeView1.Items.Clear; With TreeView1.Items Do Begin //增加根接点; TreeNode1:=Add(nil, 批量IP检测); //全部展开所有结点 TreeView1.FullExpand; //刷新TreeView TreeView1.Refresh; //根结点图标 TreeNode1.ImageIndex:=0; TreeNode1.SelectedIndex:=0; //二级接点 For h:=StrToInt(Trim(Edit2.Text)) To StrToInt(Trim(Edit3.Text)) Do Begin if ping(Trim(Edit1.Text)+.+Trim(IntToStr(h)))=True Then Begin //如果可以Ping通,图标为0; TreeNode2:=AddChild(TreeNode1,Trim(Edit1.Text)+.+IntToStr(h)); TreeNode2.ImageIndex:=0; TreeNode2.SelectedIndex:=0; //全部展开所有结点 TreeView1.FullExpand; //刷新TreeView TreeView1.Refresh; End Else Begin //如果不能Ping通,图标为1 TreeNode2:=AddChild(TreeNode1,Trim(Edit1.Text)+.+IntToStr(h)); TreeNode2.ImageIndex:=1; TreeNode2.SelectedIndex:=1; //全部展开所有结点 TreeView1.FullExpand; //刷新TreeView TreeView1.Refresh; End; End; h:=h+1; End; Label4.Caption:=检测结果:+IntToStr(i)+ 个IP不能Ping通; Application.MessageBox(检测结束,提示,0); End;
procedure TForm1.FormCreate(Sender: TObject); begin form1.TreeView1 .Brush.Bitmap:=image1.Picture.Bitmap; end;
end. |