unit Volltextsuche;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.ComCtrls, FileCtrl, System.IOUtils ,
Vcl.Buttons;
type
TMainSuche = class(TForm)
cbSuche: TComboBox;
lblSuche: TLabel;
cbZiel: TComboBox;
lblZiel: TLabel;
btnZiel: TButton;
BBstart: TBitBtn;
ListBox1: TListBox;
CheckBox1: TCheckBox;
procedure btnZielClick(Sender: TObject);
procedure BBstartClick(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
private
{ Private-Deklarationen }
procedure FileSearch(const PathName, FileName : string; const InDir : boolean);
public
{ Public-Deklarationen }
end;
var
MainSuche: TMainSuche;
OverrideCbBAdr: boolean = false;
implementation
{$R *.dfm}
uses FileInfo;
procedure TMainSuche.FileSearch(const PathName: string; const FileName: string; const InDir: Boolean);
var Rec : TSearchRec;
Path : string;
begin
Path := IncludeTrailingBackslash(PathName);
if FindFirst (Path + FileName, faAnyFile - faDirectory, Rec) = 0 then
try
repeat
Listbox1.Items.Add(Path + Rec.Name);
until FindNext (Rec) <> 0;
finally
FindClose (Rec);
end;
end;
procedure TMainSuche.btnZielClick(Sender: TObject);
var
Directory: string;
begin
Directory := 'C:\';
if SelectDirectory('Bitte ein Verzeichnis wählen.','',Directory) then
begin
if not OverrideCbBAdr then
begin
OverridecbBAdr := true;
cbZiel.Items.Insert(0,'');
end;
cbZiel.Items.Delete(0);
cbZiel.Items.Insert(0,Directory);
cbZiel.ItemIndex := 0;
end;
end;
procedure TMainSuche.BBstartClick(Sender: TObject);
begin
ListBox1.Clear;
FileSearch(cbZiel.Text, cbSuche.Text, CheckBox1.State in [cbChecked]);
end;
procedure TMainSuche.ListBox1DblClick(Sender: TObject);
var SelectedFile : string;
Rec : TSearchRec;
frInfo : TfrFileInfo;
begin
SelectedFile := ListBox1.Items.Strings[ListBox1.ItemIndex];
if FindFirst (SelectedFile, faAnyFile, Rec) = 0 then
begin
frinfo := TfrFileInfo.Create(Self);
try
frInfo.lblFile.Caption := SelectedFile;
frInfo.lblName.Caption := Rec.Name;
frInfo.lblSize.Caption := Format('%d bytes', [Rec.Size]);
frInfo.lblModified.Caption := DateToStr(fileDatetoDateTime(Rec.Time));
frInfo.lblShortName.Caption := Rec.FindData.cAlternateFileName;
frInfo.ShowModal;
finally
frInfo.Free;
end;
FindClose(Rec)
end;
end;
end.