Code:
#include <stdio.h>
#include <windows.h>
int main(void)
{
int count = 0;
ULARGE_INTEGER totalbytes, freebytes;
char drives[24][5] = {
"C:\\","D:\\","E:\\","F:\\","G:\\","H:\\","I:\\","J:\\","K:\\",
"L:\\","M:\\","N:\\","O:\\","P:\\","Q:\\","R:\\","S:\\","T:\\",
"U:\\","V:\\","W:\\","X:\\","Y:\\","Z:\\"
};
/* do a loop to check each drive */
for( count = 0 ; count<24 ; count++ )
{
/* something goes wrong, continue with next drive */
if( GetDiskFreeSpaceEx( drives[count], NULL, &totalbytes, &freebytes) == 0)
continue;
printf("\t%s\t%0.0f bytes free\t%0.0f total bytes\n",
drives[count],(double)(__int64)freebytes.QuadPart ,(double)(__int64)totalbytes.QuadPart );
}
return 0;
}
Code:
C:\ 1450516480 bytes free 6465036288 total bytes
E:\ 0 bytes free 84213760 total bytes
I did some searching around and found a way to alter the printf statement. Now it shows the correct values. I'm not sure if it's correct, but it works (so it must be correct). Thanks Salem for the link also. Good stuff to know.
scrappy