📄 unitmain.pas
字号:
unit UnitMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ShellCtrls, ExtCtrls, StdCtrls, Buttons;
type
TForm1 = class(TForm)
ShellTreeView1: TShellTreeView;
Panel1: TPanel;
Splitter1: TSplitter;
ListBox1: TListBox;
LabeledEdit1: TLabeledEdit;
CheckBox1: TCheckBox;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure LabeledEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
FFileName: String; //save kind of file
procedure FindFile(path: String);//search file
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Form1.Cursor := crHourGlass;
Listbox1.Items.Clear;//clean the listbox
FFileName := LabeledEdit1.Text;//set kind of file
try
FindFile(ShellTreeView1.Path+'\');
finally
Form1.Cursor := crDefault;//set the mouse's cursor to Default
end;
end;
procedure TForm1.FindFile(path: String);
var
FSearchRec: TSearchRec;//save the find result of the file
DSearchRec: TSearchRec;//save the find result of the directory
FindResult: ShortInt;
begin
FindResult := FindFirst(path+FFileName,faAnyFile,FSearchRec);
try
While FindResult = 0 do //if find the file
begin
ListBox1.Items.Add(path+FSearchRec.Name);//add the find file to listbox
FindResult := FindNext(FSearchRec);
end;
if CheckBox1.Checked then
begin//search the inclusive directory
FindResult := FindFirst(path+'*.*',faDirectory,DSearchRec);
While FindResult = 0 do
begin//remove the "." and "..",they are mearning current directory and father directory
if ((DSearchRec.Attr and faDirectory) = faDirectory) and
(DSearchRec.Name<>'.') and (DSearchRec.Name<>'..') then //采用递归法搜索子目录
FindFile(path+DSearchRec.Name+'\');
FindResult := FindNext(DSearchRec);
end;
end;
finally
FindClose(DSearchRec);//free the memory
end;
end;
procedure TForm1.LabeledEdit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = Vk_Return then
Keybd_Event(9,0,0,0);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -