다음을 통해 공유


GetFileSize (Windows CE 5.0)

Send Feedback

This function retrieves the size, in bytes, of the specified file. A RAPI version of this function exists, called CeGetFileSize (RAPI).

DWORDGetFileSize( HANDLEhFile, LPDWORDlpFileSizeHigh);

Parameters

  • hFile
    [in] Open handle of the file whose size is being returned. The handle must have been created with either GENERIC_READ or GENERIC_WRITE access to the file.
  • lpFileSizeHigh
    [out] Pointer to the variable where the high-order word of the file size is returned. This parameter can be NULL if the application does not require the high-order word.

Return Values

The low-order DWORD of the file size indicates success. If lpFileSizeHigh is not NULL, the function puts the high-order DWORD of the file size into the variable pointed to by that parameter. If lpFileSizeHigh is NULL, 0xFFFFFFFF indicates failure. To get extended error information, call GetLastError.

If lpFileSizeHigh is not NULL, 0xFFFFFFFF indicates failure and GetLastError returns a value other than NO_ERROR.

Remarks

If the return value is 0xFFFFFFFF and lpFileSizeHigh is not NULL, an application must call GetLastError to determine whether the function has succeeded or failed. The following code sample shows this point.

// 
// Case One: calling the function with 
//           lpFileSizeHigh == NULL 
 
// Try to obtain hFile's size 
dwSize = GetFileSize (hFile, NULL) ; 
 
// Result on failure. 
if (dwSize == 0xFFFFFFFF) { 
 
    // Obtain the error code. 
    dwError = GetLastError() ; 
 
    // Resolve the failure. 
    . 
    . 
    . 
 
    } // End of error handler 
 
 
// 
// Case Two: calling the function with 
//           lpFileSizeHigh != NULL 
 
// Try to obtain hFile's huge size. 
dwSizeLow = GetFileSize (hFile, & dwSizeHigh) ; 
 
// Result on failure. 
if (dwSizeLow == 0xFFFFFFFF 
    && 
    (dwError = GetLastError()) != NO_ERROR ){ 
 
    // Resolve the failure. 
    . 
    . 
    . 
 
    } // End of error handler. 

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.

See Also

CeGetFileSize (RAPI) | FindFirstFile | GetFileInformationByHandle

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.