SearchRec defines file information searched for by FindFirst or FindNext.UnitSysutilstype 
TSearchRec = record
Time: Integer;
Size: Integer;
Attr: Integer;
Name: TFileName;
ExcludeAttr: Integer;
FindHandle: THandle;
FindData: TWin32FindData;
end;DescriptionThe TSearchRec type defines file information searched for by a FindFirst or FindNext function call. If a file is found, the fields of the TSearchRec type parameter are modified to specify the found file.Attr represents the file attributes the file attributes of the file. Test Attr against the following attribute constants or values to determine if a file has a specific attribute:Constant Value DescriptionfaReadOnly $00000001 Read-only files
faHidden $00000002 Hidden files
faSysFile $00000004 System files
faVolumeID $00000008 Volume ID files
faDirectory $00000010 Directory files
faArchive $00000020 Archive files
faAnyFile $0000003F Any fileTo test for an attribute, combine the value of the Attr field with the attribute constant with the and operator. If the file has that attribute, the result will be greater than 0. For example, if the found file is a hidden file, the following expression will evaluate to True: (SearchRec.Attr and faHidden > 0).Time contains the time stamp of the file. This is a DOS date-and-time stamp. It can be converted to a TDateTime value using FileDateToDateTime.Size contains the size of the file in bytes. Name contains the DOS file name and extension.  FindData contains additional information such as the file creation time, last access time, and both the long and short file names.

解决方案 »

  1.   

    FindFirst functionSearches for the first instance of a file name with a given set of attributes in a specified directory.UnitSysutilsCategoryfile management routinesfunction FindFirst(const Path: string; Attr: Integer; var F: TSearchRec): Integer;DescriptionFindFirst searches the directory specified by Path for the first file that matches the file name implied by Path and the attributes specified by the Attr parameter. The result is returned in the F parameter. Use the fields of this search record to extract the information needed. FindFirst returns 0 if a file was successfully located, otherwise, it returns a Windows error code.The Path constant parameter is the directory and file name mask, including wildcard characters. For example, 'c:\test\*.*' specifies all files in the C:\TEST directory).The Attr parameter specifies the special files to include in addition to all normal files. Choose from these file attribute constants when specifying the Attr parameter:Constant Value DescriptionfaReadOnly $00000001 Read-only files
    faHidden          $00000002 Hidden files
    faSysFile          $00000004 System files
    faVolumeID $00000008 Volume ID files
    faDirectory $00000010 Directory files
    faArchive          $00000020 Archive files
    faAnyFile   $0000003F Any fileAttributes can be combined by adding their constants or values. For example, to search for read-only and hidden files in addition to normal files, pass (faReadOnly + faHidden) as the Attr parameter.Note: FindFirst allocates resources (memory) which must be released by calling FindClose.
      

  2.   

    FindNext functionReturns the next entry matching the name and attributes specified in a previous call to FindFirst.UnitSysutilsCategoryfile management routinesfunction FindNext(var F: TSearchRec): Integer;DescriptionFindNext returns the next entry that matches the name and attributes specified in a previous call to FindFirst. The search record must be one that was passed to FindFirst. The return value is zero if the function was successful. Otherwise the return value is a Windows error code.