1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <windows.h>
#include <tchar.h>
int __cdecl _tmain(__in int argc, __in_ecount_z(argc) TCHAR* argv[], __in_z TCHAR* envp[])
{
PULARGE_INTEGER pulAvailable = 0, pulTotal = 0, pulFree = 0;
if(!GetDiskFreeSpaceEx(NULL, &pulAvailable, &pulTotal, &pulFree))
{
DWORD dwSectorsPerCluster = 0, dwBytesPerSector = 0;
DWORD dwFreeClusters = 0, dwTotalClusters = 0;
if(!GetDiskFreeSpaceA(NULL, &dwSectorsPerCluster,
&BytesPerSector, &FreeClusters, &TotalClusters))
{
_tprintf(_T("Couldn't get free disk space.."));
return EXIT_FAILURE;
}
dwFreeBytes = dwFreeClusters * dwSectorsPerCluster * dwBytesPerSector;
dwTotalBytes = dwTotalClusters * dwSectorsPerCluster * dwBytesPerSector;
// do something with dwFreeBytes & dwTotalBytes
}
// do something with pulAvailable, pulTotal, & pulFree
return EXIT_SUCCESS;
}
|