使用方式如下:
char szDiskDir[MAX_PATH] = "C:\\";
//A pointer to a variable that receives the total number of free bytes on a disk that are available to the user who is associated with the calling thread.
//This parameter can be NULL.
//If per-user quotas are being used, this value may be less than the total number of free bytes on a disk.
__int64 n64AvailableFreeDiskBytes;
//A pointer to a variable that receives the total number of bytes on a disk that are available to the user who is associated with the calling thread.
//This parameter can be NULL.
//If per-user quotas are being used, this value may be less than the total number of bytes on a disk.
//To determine the total number of bytes on a disk or volume, use IOCTL_DISK_GET_LENGTH_INFO.
__int64 n64TotalDiskBytes;
//A pointer to a variable that receives the total number of free bytes on a disk.
//This parameter can be NULL.
__int64 n64TotalFreeDiskBytes;
if ( !::GetDiskFreeSpaceEx(szDiskDir, (PULARGE_INTEGER) &n64AvailableFreeDiskBytes, (PULARGE_INTEGER) &n64TotalDiskBytes,
(PULARGE_INTEGER) &n64TotalFreeDiskBytes) )
{
printf("Fail to get disk fress space in %s (Err = %d).\n", szDiskDir, ::GetLastError());
}else{
printf("%s has %lld bytes available free disk.\nTotal disk size is %lld bytes.\nTotal free space is %lld bytes.\n",
szDiskDir, n64AvailableFreeDiskBytes, n64TotalDiskBytes, n64TotalFreeDiskBytes);
}