GetFileSize
Retrieves the size of the specified file.
Syntax
DWORD GetFileSize(
HANDLE hFile,
LPDWORD lpFileSizeHigh
);
Parameters
| Parameter | Description |
|---|---|
hFile |
A handle to the file. |
lpFileSizeHigh |
A pointer to a 32-bit unsigned integer that receives the high-order bits of the file size. This parameter can be NULL. |
Return Value
If the function succeeds, the return value is the low-order 32 bits of the specified file's size, and if lpFileSizeHigh is not NULL, it contains the high-order 32 bits of the file size. If the file size is greater than 4 GB, lpFileSizeHigh must not be NULL.
If the function fails, the return value is INVALID_FILE_SIZE (-1), and to get extended error information, call GetLastError.
Remarks
To get the size of a file, you typically use the GetFileSizeEx function. GetFileSize is provided for compatibility with earlier versions of Windows.
The return value is the low-order 32 bits of the file size. The high-order 32 bits are returned in the DWORD pointed to by lpFileSizeHigh.
If the file size is less than 4 GB, the return value of GetFileSize is sufficient. If the file size is 4 GB or larger, you must use the lpFileSizeHigh parameter to retrieve the full size.
If lpFileSizeHigh is NULL, GetFileSize returns 0xFFFFFFFF (4,294,967,295) for files that are 4 GB or larger. If your application needs to handle files of this size, you must use GetFileSizeEx.
The handle to the file must have been created with the GENERIC_READ access right.