GetDiskFreeSpaceEx

This function obtains information about the amount of space available on a disk volume: the total amount of space, the total amount of free space, and the total amount of free space available to the user associated with the calling thread.

At a Glance

Header file: Winbase.h
Versions: 2.0 and later

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 disk of interest. This string can be a UNC name. If this parameter is a UNC name, you must follow it with an additional backslash. For example, you would specify \\MyServer\MyShare as \\MyServer\MyShare\.

If lpDirectoryName is NULL, the GetDiskFreeSpaceEx function obtains information about the object store.

Note that lpDirectoryName does not have to specify the root directory on a disk. The function accepts any directory on the disk.

lpFreeBytesAvailableToCaller

[out] Pointer to a variable to receive the total 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 total 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 NULL.

Return Values

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

Remarks

Note that the values obtained by this function are of type ULARGE_INTEGER. Be careful not to truncate these values to 32 bits.