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 Win32-based applications should use GetDiskFreeSpaceEx.
BOOL GetDiskFreeSpace(
LPCTSTR lpRootPathName, // pointer to root path
LPDWORD lpSectorsPerCluster, // pointer to sectors per cluster
LPDWORD lpBytesPerSector, // pointer to bytes per sector
LPDWORD lpNumberOfFreeClusters,
// pointer to number of free clusters
LPDWORD lpTotalNumberOfClusters
// pointer to total number of clusters
);
Windows 95: The initial release of Windows 95 does not support UNC paths for the lpszRootPathName parameter. To query the free disk space using a UNC path, temporarily map the UNC path to a drive letter, query the free disk space on the drive, then remove the temporary mapping. Windows 95 OSR2 and later: UNC paths are supported.
Windows NT 5.0 and later: If per-user disk quotas are in use, this value may be less than the total number of free clusters on the disk.
Windows NT 5.0 and later: If per-user disk quotas are in use, this value may be less than the total number of clusters on the disk.
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 NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
File I/O Overview, File Functions, GetDiskFreeSpaceEx, GetDriveType