Einzelnen Beitrag anzeigen

Benutzerbild von SaFu
SaFu

Registriert seit: 8. Nov 2006
1.360 Beiträge
 
Delphi 10.3 Rio
 
#11

Re: Findfirst,Findnext schulung

  Alt 23. Jul 2007, 15:23
OK
habe es jetzt so

Delphi-Quellcode:
 
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,DateUtils, FileCtrl;

type
  TFindFilesOption = (ffoExcludePath, ffoExcludeExt);
    TFindFilesOptions = set of TFindFilesOption;
    TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);

  private
   function FindFiles(const fileExpr: String; files: TStrings;options: TFindFilesOptions): Boolean; { Private-Deklarationen }

  public
   { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function TForm1.FindFiles(const fileExpr: String; files: TStrings;
  options: TFindFilesOptions): Boolean;
var
  sr2: TSearchRec;
  path2: string;
  extWanted: Boolean;
begin
  Result := True;
  files.Clear;
  files.BeginUpdate;
  if ffoExcludePath in options
    then path2 := ''
    else path2 := ExtractFilePath(fileExpr);
  extWanted := not (ffoExcludeExt in options);
  if FindFirst(fileExpr, faArchive, sr2) = 0 then
  begin
    repeat
      if extWanted
        then files.Add(path2 + sr2.Name)
        else files.Add(ChangeFileExt(path2 + sr2.Name, ''));
    until FindNext(sr2) <> 0;
    FindClose(sr2);
  end else Result := False;
  files.EndUpdate;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 FindFiles('c:\WINDOWS\'+ '\*', ListBox1.Items, [ffoExcludePath, ffoExcludeExt]);
end;

end.
aber geht das jetzt auch kurzer das war ja ohne endungen
"... Wie gesagt, die Nutzer von 10, 12, 14 Zoll Display's werden deine Seite nicht in voller Pracht sehen können, ...

Surft Ihr mit dem Taschenrechner?"
  Mit Zitat antworten Zitat