Code snippet below to detect maximum and available hard drive space.
Bob
Code:
#include <windows.h>
#include <stdio.h>
int main(void)
{
unsigned __int64 i64TotalBytes, i64AvailableBytes;
BOOL bReturn;
char *pDrive = "C:\\";
DWORD dwSectorsPerCluster,
dwBytesPerSector,
dwFreeClusters,
dwTotalClusters;
bReturn = GetDiskFreeSpace (pDrive,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwFreeClusters,
&dwTotalClusters);
if (bReturn)
{
/* cast it to 64 bits for calculations */
i64TotalBytes = (__int64)dwTotalClusters * dwSectorsPerCluster * dwBytesPerSector;
i64AvailableBytes = (__int64)dwFreeClusters * dwSectorsPerCluster * dwBytesPerSector;
printf ("Available = %I64u MB\n", i64AvailableBytes / (1024*1024));
printf ("Total = %I64u MB\n",i64TotalBytes / (1024*1024));
}
else
printf("GetDiskFreeSpace failed\n");
return 0;
}