我要查找‘d:\管理系统’目录下的exe文件并把它们加到combobox中,给个思路
和所用函数就给分

解决方案 »

  1.   

    procedure ShowYTType(CBYTInfo: TComboBox; FPath: string; MaskExe: string);
    procedure TFrmSetup.ShowYTType(CBYTInfo: TComboBox; FPath,
      MaskExe: string);
    var
      Files: TStrings;
      i: integer;
    begin
      Files := TStringList.Create;
      SearchFileEx(FPath, '.exe', Files);
      //CBYTInfo.Items.Add('无');
      for i := 0 to Files.Count - 1 do
      begin
        CBYTInfo.Items.Add(ExtractFileName(Files[i]));
      end;
      Files.Free;
    end;procedure SearchFileEx(const Dir, Ext: string; Files: TStrings);
    var
      Found: TSearchRec;
      i: integer;
      Dirs: TStrings;
      Finished: integer;
      StopSearch: Boolean;
    begin
      StopSearch := False;
      Dirs := TStringList.Create;
      Finished := FindFirst(Dir + '*.*', 63, Found);
      while (Finished = 0) and not (StopSearch) do
      begin
        if (Found.Name <> '.') then
        begin
          if (Found.Attr and faDirectory) = faDirectory then
            Dirs.Add(Dir + Found.Name)
          else
            if Pos(UpperCase(Ext), UpperCase(Found.Name)) > 0 then
              Files.Add(Dir + Found.Name);
        end;
        Finished := FindNext(Found);
      end;
      FindClose(Found);
      if not StopSearch then
        for i := 0 to Dirs.Count - 1 do
          SearchFileEx(Dirs[i], Ext, Files);
      Dirs.Free;
    end;
      

  2.   

    点解要用combobox?用directorylistbox不更方便吗
      

  3.   

    用win3.1面板中的filelistbox,directorylistbox,drivercombox,三者结合,再加上过滤,
    我想所有的文件都能给提出来的,试试吧