System.SysUtils.TSearchRec

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

TSearchRec = record

C++

struct DECLSPEC_DRECORD TSearchRec
{
private:
    System::TDateTime __fastcall GetCreationTime();
    System::TDateTime __fastcall GetLastAccessTime();
    System::TDateTime __fastcall GetTimeStamp();
public:
    int Time _DEPRECATED_ATTRIBUTE0 ;
    __int64 Size;
    int Attr;
    TFileName Name;
    int ExcludeAttr;
    Winapi::Windows::THandle FindHandle;
    Winapi::Windows::TWin32FindData FindData;
    __property System::TDateTime CreationTime = {read=GetCreationTime};
    __property System::TDateTime LastAccessTime = {read=GetLastAccessTime};
    __property System::TDateTime TimeStamp = {read=GetTimeStamp};
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

TSearchRec defines file information searched for by FindFirst or FindNext.

The 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 of the file. Test Attr against the following attribute constants or values to determine whether a file attribute matches the file's properties.

Note: Attribute constants map directly to DOS file attributes.

Constant Value Description

faReadOnly

1

Read-only files

faHidden

2

Hidden files

faSysFile

4

System files

faVolumeID

8

Volume ID files

faDirectory

16

Directory files

faArchive

32

Archive files

faSymLink

64

Symbolic link

faAnyFile

71

Any file

The faReadOnly constant has the same name as the enumerated value that is defined by the TFieldAttribute type. If both the System.SysUtils and Data.DB units are used in your source files, you must disambiguate by specifying the unit to qualify the use of faReadOnly. That is, write SysUtils.faReadOnly (Delphi) or SysUtils::faReadOnly (C++).

To test an attribute, combine the value of the Attr field with the attribute constant using 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
(SearchRec.Attr & faHidden) != 0

Time contains the time stamp of the file. It can be converted to a TDateTime value using FileDateToDateTime.

Size contains the size of the file, in bytes.

Name contains the base file name, including extension.

FindHandle is an internal handle used to track a 'find' state.

FindData contains additional information such as the file creation time, last access time, and both the long and short file names.

See Also

Code Examples