GetFileInformationByHandle
Retrieves information about the specified file.
BOOL GetFileInformationByHandle(
HANDLE hFile,
LPBY_HANDLE_FILE_INFORMATION lpFileInformation
);
Parameters
| Parameter | Type | Description |
|---|---|---|
hFile |
HANDLE | A handle to the file for which to retrieve information. This handle must have been created with read access. |
lpFileInformation |
LPBY_HANDLE_FILE_INFORMATION | A pointer to a BY_HANDLE_FILE_INFORMATION structure that receives information about the file. |
Return Value
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The GetFileInformationByHandle function retrieves information about the file associated with the specified handle.
The BY_HANDLE_FILE_INFORMATION structure contains the following members:
dwFileAttributes: The file attributes. For a list of possible values, see theFileAttribute*constants.ftCreationTime: AFILETIMEstructure that specifies the date and time the file was created.ftLastAccessTime: AFILETIMEstructure that specifies the date and time the file was last accessed.ftLastWriteTime: AFILETIMEstructure 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 32 bits of the file size.nFileSizeLow: The low-order 32 bits of the file size.nNumberOfLinks: The number of links to the file.nFileIndexHigh: The high-order 32 bits of the file's unique identifier on disk.nFileIndexLow: The low-order 32 bits of the file's unique identifier on disk.
Important:
Ensure that the handle provided to
GetFileInformationByHandle was opened with at least read access. Otherwise, the function may fail with ERROR_ACCESS_DENIED.
Requirements
| Minimum supported client | Windows XP with SP1, Windows Vista, Windows 7, Windows 8, Windows 10 |
| Minimum supported server | Windows Server 2003 with SP1, Windows Server 2008, Windows Server 2012, Windows Server 2016 |
| Header | fileapi.h (include windows.h) |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |