GetFileInformationByHandleEx

🔗 #

The GetFileInformationByHandleEx function retrieves file information for a specified file handle.

Syntax


BOOL WINAPI GetFileInformationByHandleEx(
  _In_ HANDLE                      hFile,
  _In_ FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
  _Out_LPVOID                     lpFileInformation,
  _In_ DWORD                     dwBufferSize
);
            

Parameters

Parameter Description
hFile A handle to the file for which to retrieve information. This handle must have been created with the appropriate access rights.
FileInformationClass The type of file information to retrieve. This can be one of the FILE_INFO_BY_HANDLE_CLASS enumeration values.
lpFileInformation A pointer to a buffer that receives the requested file information. The structure of this buffer depends on the value of FileInformationClass.
dwBufferSize The size of the buffer pointed to by lpFileInformation, in bytes.

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

This function is an extended version of GetFileInformationByHandle, allowing for retrieval of more detailed file information.

The FileInformationClass parameter determines the type of structure that should be passed in the lpFileInformation parameter. Common classes include:

  • FileBasicInfo: Retrieves basic file information (creation time, last access time, last write time, change time, and file attributes).
  • FileStandardInfo: Retrieves standard file information (allocation size, end of file, number of links, delete pending flag, and compressed flag).
  • FileIdBothDirectoryInfo: Retrieves directory entry information, including file ID and name.
  • FileBothDirectoryInfo: Similar to FileIdBothDirectoryInfo but without the file ID.
Note: Ensure that the handle hFile was opened with sufficient access rights to query the requested information. For example, to retrieve basic information, the handle usually needs at least FILE_READ_ATTRIBUTES access.

See Also