Einzelnen Beitrag anzeigen

Bernd29bln

Registriert seit: 28. Feb 2005
Ort: Berlin
281 Beiträge
 
Delphi 7 Professional
 
#21

Re: Festplatte durchsuchen lassen???

  Alt 23. Mär 2005, 12:21
HI Matze,

habs mal ausprobiert listbox bleibt leer hier mal der code.

Delphi-Quellcode:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure FindAllFiles(RootFolder: string; Mask: string = '*.*'; Recurse: Boolean = True);
var
  SR: TSearchRec;
begin
  RootFolder := IncludeTrailingPathDelimiter(RootFolder);

  if Recurse then
    if FindFirst(RootFolder + '*.*', faAnyFile, SR) = 0 then
      try
        repeat
          if SR.Attr and faDirectory = faDirectory then
            if (SR.Name <> '.') and (SR.Name <> '..') then
              FindAllFiles(RootFolder + SR.Name, Mask, Recurse);
        until FindNext(SR) <> 0;
      finally
        FindClose(SR);
      end;
  if FindFirst(RootFolder + Mask, faAnyFile, SR) = 0 then
    try
      repeat
        if SR.Attr and faDirectory <> faDirectory then
        begin
          Form1.ListBox1.Items.Add(RootFolder + SR.Name);
        end;
      until FindNext(SR) <> 0;
    finally
      FindClose(SR);
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 FindAllFiles('c:\mp3s\', '*.mp3', true);
end;

end.
gruss bernd
Bernd
  Mit Zitat antworten Zitat