The GetDiskFreeSpace function retrieves information about the specified disk, including the amount of free space on the disk.
This function has been superseded by the GetDiskFreeSpaceEx function. New applications should use GetDiskFreeSpaceEx.
BOOL GetDiskFreeSpace(
LPCTSTR lpRootPathName, |
// address of root path |
LPDWORD lpSectorsPerCluster, |
// address of sectors per cluster |
LPDWORD lpBytesPerSector, |
// address of bytes per sector |
LPDWORD lpNumberOfFreeClusters, |
// address of number of free clusters |
LPDWORD lpTotalNumberOfClusters |
// address of total number of clusters |
); |
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
The GetDiskFreeSpaceEx function lets you avoid the arithmetic required by the GetDiskFreeSpace function.
Even on volumes that are smaller than 2 gigabytes, the values stored into *lpSectorsPerCluster, *lpNumberOfFreeClusters, and *lpTotalNumberOfClusters values may be incorrect. That is because the operating system manipulates the values so that computations with them yield the correct volume size.
Windows 95 OSR 2: The GetDiskFreeSpaceEx function is available on Windows 95 systems beginning with OEM Service Release 2 (OSR 2). The GetDiskFreeSpaceEx function returns correct values for all volumes, including those that are greater than 2 gigabytes.
GetDiskFreeSpaceEx, GetDriveType
See: