GetDiskFreeSpace returns wrong total clusters under XP
Posted on 2004-11-10
I have some code that was working under Windows 2000 but returns bizarre results under XP (SP1).
GetDiskFreeSpace on a diskette drive returns 805,306,368 (0x30000000) for TotalNumberOfClusters. GetDiskFreeSpaceEx returns 1,407,374,883,553,280 (0x0005000000000000) for TotalNumberOfBytes.
The above was using "A:\\" as the volume name. However I tried "C:\\", "X:\\" (where X drive is not present) and even "?:\\" and I always get the same result from GetDiskFreeSpace and GetDiskFreeSpaceEx (which do not return 0 for error). SectorsPerCluster always returns 4096 and BytePerSector is always 512. I doubt these values are the same for A: and C:.
And why does GetDiskFreeSpace on "?:\\" not even return an error.
I searched help and the web on this problem but could not find a mention of it.
I realise that I can use IOCTL_DISK_GET_LENGTH_INFO, but what is wrong with GetDiskFreeSpace under XP?!?