GetFileInformationByHandle
The GetFileInformationByHandle
function retrieves information about a specified open file.
Related Functions
- CreateFile
- Opens or creates a file or I/O device.
- CloseHandle
- Closes an open object handle.
Parameters
hFile
-
A handle to the file for which information is to be retrieved. The handle must have been created by the
CreateFile
function or by another function that returns a file handle, and it must have theFILE_GENERIC_READ
access right. lpFileInformation
-
A pointer to a
BY_HANDLE_FILE_INFORMATION
structure that receives the file information. See the structure definition below for details.
Return Value
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError
.
Remarks
The GetFileInformationByHandle
function returns information about the file associated with the specified handle. This includes attributes, creation time, last access time, last write time, and volume serial number.
The information returned is specific to the file's current state and may not reflect changes made after the handle was opened.
Structures
BY_HANDLE_FILE_INFORMATION
Contains file information returned by the GetFileInformationByHandle
function.
Members
dwFileAttributes
- The file attributes. This member can be one or more of the following values:
FILE_ATTRIBUTE_ARCHIVE
,FILE_ATTRIBUTE_COMPRESSED
,FILE_ATTRIBUTE_DIRECTORY
,FILE_ATTRIBUTE_ENCRYPTED
,FILE_ATTRIBUTE_HIDDEN
,FILE_ATTRIBUTE_NORMAL
,FILE_ATTRIBUTE_OFFLINE
,FILE_ATTRIBUTE_READONLY
,FILE_ATTRIBUTE_REPARSE_POINT
,FILE_ATTRIBUTE_SPARSE_FILE
,FILE_ATTRIBUTE_SYSTEM
,FILE_ATTRIBUTE_TEMPORARY
. ftCreationTime
- A
FILETIME
structure that specifies the date and time the file was created. ftLastAccessTime
- A
FILETIME
structure that specifies the date and time the file was last accessed. ftLastWriteTime
- A
FILETIME
structure that specifies the date and time the file was last written to. dwVolumeSerialNumber
- The serial number of the volume that holds the file.
nFileSizeHigh
- The high-order bits of the file size. This member is valid only if the file is not a directory.
nFileSizeLow
- The low-order bits of the file size. This member is valid only if the file is not a directory.
nNumberOfLinks
- The number of links to the file.
nFileIndexHigh
- The high-order part of the file index.
nFileIndexLow
- The low-order part of the file index.
Requirements
Header
windows.h
Library
Kernel32.lib
DLL
Kernel32.dll