size : 1422 uploaded_on : Tue May 11 00:00:00 1999 modified_on : Wed Dec 8 14:03:40 1999 title : Find a file org_filename : FindAFile.txt author : Bruce Roberts authoremail : ber@attcanada.net description : How to search the computer for a file keywords : tested : not tested yet submitted_by : The CKB Crew submitted_by_email : ckb@netalive.org uploaded_by : nobody modified_by : nobody owner : nobody lang : plain file-type : text/plain category : delphi-filehandling __END_OF_HEADER__ function FindAFile (srchName : string) : string; var nxtDrv, drvList : pChar; filePath : string; ListLength : integer; function SearchForFile (srch, path : string) : string; var sRslt : integer; sRec : tSearchRec; begin if FileExists (path + srch) then result := path + srch else begin result := ''; sRslt := FindFirst (path + '*.*', faDirectory, sRec); try while (result = '') and (sRslt = 0) do begin if ((sRec.Attr and faDirectory) > 0) and (sRec.Name <> '.') and (sRec.Name <> '..') then result := SearchForFile (srch, path + sRec.Name + '\'); sRslt := FindNext (sRec); end; finally FindClose (sRec); end; end; end; begin filePath := ''; ListLength := GetLogicalDriveStrings (0, nil); drvList := StrAlloc (ListLength); try GetLogicalDriveStrings (ListLength, drvList); nxtDrv := drvList; while (filePath = '') and (nxtDrv^ <> #0) do begin if (GetDriveType (nxtDrv) = DRIVE_FIXED) then filePath := SearchForFile (srchName, String (nxtDrv)); nxtDrv := nxtDrv + Length (nxtDrv) + 1; end; finally StrDispose (drvList); end; result := filePath; end;