C
chinaxuguojun
Unregistered / Unconfirmed
GUEST, unregistred user!
代码很简单,就是在主窗上放上一个 Button1 然后写上事件,就可以了,但就是调用不出来啊
怪怪的
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FStringList: TStringList;
procedure FileExeFile(Path: string;FileType: Integer);
public
end;
var
Form1: TForm1;
implementation
uses FileCtrl,StrUtils;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
path: string;
FileAttrs: Integer;
begin
FileAttrs := faAnyFile;//faReadOnly + faHidden + faSysFile + faDirectory + faArchive;
SelectDirectory('','',path);
if path <> '' then
begin
FileExeFile(path,FileAttrs)
end else
begin
showmessage('请选择路径!');
end;
end;
procedure TForm1.FileExeFile(Path: string;FileType: Integer);
var
sr: TSearchRec;
begin
FStringList.Clear;
if FindFirst(Path,FileType, sr) = 0 then
begin
repeat
if (sr.Attr and FileType) = faDirectory then
FileExeFile(Path + '/' + Sr.Name,FileType);
if (sr.Attr and FileType) = sr.Attr then
begin
if UpperCase(RightStr(Sr.Name,4)) = '.EXE' then
FStringList.Add(Path + '/' + Sr.Name);
end;
until FindNext(sr) <> 0
FindClose(sr);
FStringList.SaveToFile('Result.txt');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FStringList := TStringList.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FStringList.Free;
end;
end.
怪怪的
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FStringList: TStringList;
procedure FileExeFile(Path: string;FileType: Integer);
public
end;
var
Form1: TForm1;
implementation
uses FileCtrl,StrUtils;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
path: string;
FileAttrs: Integer;
begin
FileAttrs := faAnyFile;//faReadOnly + faHidden + faSysFile + faDirectory + faArchive;
SelectDirectory('','',path);
if path <> '' then
begin
FileExeFile(path,FileAttrs)
end else
begin
showmessage('请选择路径!');
end;
end;
procedure TForm1.FileExeFile(Path: string;FileType: Integer);
var
sr: TSearchRec;
begin
FStringList.Clear;
if FindFirst(Path,FileType, sr) = 0 then
begin
repeat
if (sr.Attr and FileType) = faDirectory then
FileExeFile(Path + '/' + Sr.Name,FileType);
if (sr.Attr and FileType) = sr.Attr then
begin
if UpperCase(RightStr(Sr.Name,4)) = '.EXE' then
FStringList.Add(Path + '/' + Sr.Name);
end;
until FindNext(sr) <> 0
FindClose(sr);
FStringList.SaveToFile('Result.txt');
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FStringList := TStringList.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FStringList.Free;
end;
end.