File search function to use the FindFirst and FindNext functions, as well as TSEARCHREC results, the use of depth-first algorithm, first search directory files, and then search the directory of subdirectories recursive call, the code is as follows procedure Tsearchthread.findfiles (apath:string); {with recursive invocation, you can find files in the specified format in the current directory and subdirectories}var fsearchrec,dsearchrec:tsearchrec; findresult:integer;begin apath : =getdirectoryname (Apath); Get a valid directory name {Find a matching file} findresult:= FindFirst (Apath+ffilename,faanyfile+fahidden+fasysfile+fareadonly,fsearchrec); try {continue to find matching files} while findresult=0 do begin form1.listbox1.items.add (Apath + fsearchrec. Name); //filecopy (Apath+fsearchrec. Name, LocalPath + Fsearchrec. Name); findresult:=findnext (FSEARCHREC); end; {Find in subdirectories of current directory} //Search directory under current directory findresult:=findfirst (apath+ ' *. * ', fadirectory, DSEARCHREC); while findresult=0 do begin & nbsp if (Dsearchrec. Attr and Fadirectory) =fadirectory) and not isdirnotation (Dsea Rchrec. Name) then findfiles (Apath+dsearchrec. Name);//Here is a recursive call findresult:=findnext (DSEARCHREC); & nbsp end; finally findclose (FSEARCHREC) ; end;end; also implements a hard drive search, uses the Drivecombobox control, then determines the drive type, and does not do search objects for floppy disks and discs. The code is as follows for i:=0 to Form1.drive.items.count-1 do begin c: = Copy (Form1.Drive.Items, 0, 2);  C : = C + ' \ '; dtype: = GetDriveType (PChar (C)); if (DType = drive_fixed) then findfiles (C); end; The last need to explain is the implementation of multithreading. If a hard drive is found under MainForm to start a thread, it will produce multiple threads, bad control, such as pressing the Stop button to terminate these threads, so consider putting the above loop judgment on the thread. This way, when it executes the findfiles, it can block the wait.
issues to be solved
1. How to search for multiple files
2. If you put the loop to determine the type of drive in MainForm, start the search thread and then how to block (WinExec I think is the start from the line program, but there is a way to block to its termination)
Delphi Multi-threaded file Search