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;
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;
我想所有的文件都能给提出来的,试试吧