GetDiskFreeSpaceEx (Compact 2013)

3/26/2014

This function obtains the following information about the amount of space available on a disk volume:

  • Total amount of space
  • Amount of free space
  • Amount of free space available to the user associated with the calling thread

Syntax

BOOL GetDiskFreeSpaceEx( 
  LPCWSTR lpDirectoryName, 
  PULARGE_INTEGER lpFreeBytesAvailableToCaller, 
  PULARGE_INTEGER lpTotalNumberOfBytes, 
  PULARGE_INTEGER lpTotalNumberOfFreeBytes 
);

Parameters

  • lpDirectoryName
    [in] Pointer to a null-terminated string that specifies a directory on the specified disk. This string can be a Universal Naming Convention (UNC) name.

    If this parameter is set to NULL, this function obtains information about the object store.

    Note

    This parameterdoes not have to specify the root directory on a disk. This function accepts any directory on the disk.

  • lpFreeBytesAvailableToCaller
    [out] Pointer to a variable to receive the number of free bytes on the disk that are available to the user associated with the calling thread.
  • lpTotalNumberOfBytes
    [out] Pointer to a variable to receive the number of bytes on the disk that are available to the user associated with the calling thread.
  • lpTotalNumberOfFreeBytes
    [out] Pointer to a variable to receive the total number of free bytes on the disk.

    This parameter can be set to NULL.

Return Value

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

The values obtained by this function are of type ULARGE_INTEGER. Be sure not to truncate these values to 32 bits.

When Mobile Encryption is enabled, the reporting behavior of this function changes. Each encrypted file has at least one 4-KB page of overhead associated. This function takes this overhead into account when it reports the amount pf space available. That is, if a 128-KB disk contains a single 60-KB file, this function reports that 64 KB is available, subtracting the space occupied by both the file and its associated overhead.

Although this function reports the total available space, keep the space requirement for encrypted files in mind when estimating whether multiple new files will fit into the remaining space. Include the amount of space required for overhead when Mobile Encryption is enabled. Each file requires at least an additional 4 KB. For example, a single 60-KB file requires 64 KB, but two 30-KB files actually require 68 KB.

Requirements

Header

winbase.h

Library

coredll.lib

See Also

Reference

File I/O Functions