delphi7做了一个资源管理器。
但是不会搜索指定目录,请高人指点一下~。不胜感激!

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,shellapi,FileCtrl;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        ListBox1: TListBox;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
        procedure SearchFiles(CurrentPath : AnsiString);
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    procedure TForm1.SearchFiles(CurrentPath : AnsiString);
    var
      sr : TSearchRec;
      FileInfo : TSHFileInfo;
      iFound : Integer;
    begin
      iFound := FindFirst(CurrentPath + '*.*', faAnyFile, sr);
      while iFound=0 do
      begin
        if (sr.Attr<>faDirectory)and(sr.Name<>'.')and(sr.Name<>'..') then
        begin
          SHGetFileInfo(PChar(CurrentPath+sr.Name), 0, FileInfo, SizeOf(FileInfo), SHGFI_TYPENAME);
          ListBox1.Items.Add(FileInfo.szTypeName);
        end;
        iFound := FindNext(sr);
      end;
      FindClose(sr);
    end;procedure TForm1.Button1Click(Sender: TObject);
    var
      SelectPath : AnsiString;
    begin
      SelectPath := '';
      if SelectDirectory('请您选择分类库所对应的路径:', '', SelectPath) then
      begin
        if Length(SelectPath) <> 3 then
          SelectPath := SelectPath + '\';
        ListBox1.Items.Clear;
        SearchFiles(SelectPath);
      end;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      ListBox1.Items.Clear;
      SearchFiles('C:\Winnt\system32\');
    end;end.
      

  2.   

    需要更正:
    uses QDialogs;procedure TForm1.Button1Click(Sender: TObject);
    var
      SelectPath: WideString;
    begin
      {...}
      if SelectDirectory('路径: ', '' , SelectPath) then
      {...}
    end;