File Management Functions


GetFileInformationByHandleEx Function

Retrieves file information for the specified file.

For a more basic version of this function, see GetFileInformationByHandle.

To set file information using a file handle, see SetFileInformationByHandle.

Syntax

C++
BOOL WINAPI GetFileInformationByHandleEx(
  __in   HANDLE hFile,
  __in   FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
  __out  LPVOID lpFileInformation,
  __in   DWORD dwBufferSize
);

Parameters

hFile [in]

A handle to the file that contains the information to be retrieved.

This handle should not be a pipe handle.

FileInformationClass [in]

A FILE_INFO_BY_HANDLE_CLASS enumeration value that specifies the type of information to be retrieved.

For a table of valid values, see the Remarks section.

lpFileInformation [out]

A pointer to the buffer that receives the requested file information. The structure that is returned corresponds to the class that is specified by FileInformationClass. For a table of valid structure types, see the Remarks section.

dwBufferSize [in]

The size of the lpFileInformation buffer, in bytes.

Return Value

If the function succeeds, the return value is nonzero and file information data is contained in the buffer pointed to by the lpFileInformation parameter.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

If FileInformationClass is FileStreamInfo and the calls succeed but no streams are returned, the error that is returned by GetLastError is ERROR_HANDLE_EOF.

Certain file information classes behave slightly differently on different operating system releases. These classes are supported by the underlying drivers, and any information they return is subject to change between operating system releases.

The following table shows the valid file information class types and their corresponding data structure types for use with this function.

FileInformationClass valuelpFileInformation type
FileBasicInfoFILE_BASIC_INFO
FileStandardInfoFILE_STANDARD_INFO
FileNameInfoFILE_NAME_INFO
FileStreamInfoFILE_STREAM_INFO
FileCompressionInfoFILE_COMPRESSION_INFO
FileAttributeTagInfoFILE_ATTRIBUTE_TAG_INFO
FileIdBothDirectoryInfoFILE_ID_BOTH_DIR_INFO
FileIdBothDirectoryRestartInfoFILE_ID_BOTH_DIR_INFO
FileRemoteProtocolInfoFILE_REMOTE_PROTOCOL_INFO

 

Transacted Operations

If there is a transaction bound to the thread at the time of the call, then the function returns the compressed file size of the isolated file view. For more information, see About Transactional NTFS.

Requirements

Minimum supported clientWindows Vista
Minimum supported serverWindows Server 2008
RedistributableWindows SDK on Windows Server 2003 and Windows XP.
HeaderWinBase.h (include Windows.h), FileExtd.h on Windows Server 2003 and Windows XP
LibraryKernel32.lib, FileExtd.lib on Windows Server 2003 and Windows XP
DLLKernel32.dll

See Also

File Management Functions
SetFileInformationByHandle

Send comments about this topic to Microsoft

Build date: 10/22/2009

Tags :


Page view tracker