W
wp231957
Unregistered / Unconfirmed
GUEST, unregistred user!
unit saomiao32;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, FileCtrl;<br><br>type<br> TForm1 = class(TForm)<br> ListBox1: TListBox;<br> Button1: TButton;<br> FileListBox1: TFileListBox;<br> procedure FormCreate(Sender: TObject);<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> filelistbox1.Directory :='c:/windows/system32';<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> filenamelist:tstringlist;<br> i,j:integer;<br> str,filename:string;<br> findbz:boolean;<br>begin<br> try<br> filenamelist:=tstringlist.Create ;<br> //标准文件列表<br> filenamelist.LoadFromFile(ExtractFilePath(Application.ExeName)+'system32.txt');<br> //第一重循环是当前硬盘上SYSTEM32文件列表<br> for i:=0 to filelistbox1.Items.Count -1 do begin<br> //第2重循环是标准文件列表<br> for j:=0 to filenamelist.Count -1 do begin<br> str:=filenamelist[j];<br> //从文本文件中取文件名<br> filename:=copy(str,1,pos('-',str)-2) ;<br> //默认找到标志为假<br> findbz:=false;<br> if filelistbox1.Items=filename then begin<br> findbz:=true; //如果相等,则找到成功并终止本轮循环,进入下一轮<br> break;<br> end;<br> end;<br> application.ProcessMessages ;<br> //如果没有找到,则追加到LISTBOX1<br> if not findbz then listbox1.Items.Add(filelistbox1.Items) ;<br> end;<br> finally<br> filenamelist.Free ;<br> showmessage('SYSTEM32目录下共有'+inttostr(filelistbox1.Items.Count)+'个文件'+#13#10+'现在共有'+<br> inttostr(listbox1.Count)+'个文件与标准文件不符');<br> end;<br>end;<br><br>end.