>>I know. GetDiskFreeSpace() returns the bytes per sector and the sectors per cluster, in addition to other information.
>
>OK, thank you very much. I am new to Win-API; and I thought: GetDiskFreeSpace() only gives me the free disk space.
>
>>
>>>I wrote a small utility, which I called "Who's gobbling my hard disk", that totals file sizes for each folder. For accurate information, for a specific disk, I need the cluster size. For instance, on my current "C:" drive, a 100-byte batch-file actually uses 4 KB, because that is the cluster size I am using.
>>>
>>>Since sys(2022) isn't trustworthy (see my original message), I gave the user the option of selecting the cluster size.
>>
>>How?
>
>A combobox on the main form. The options are: "Auto" (i.e., autodetect), "512 bytes", "1 KB", "2 KB", ..., "32 KB" (all powers of 2 in between).
>
>>The only reliable way to do it across all Win32 platform and file systems is to write get the amount of free space, write a small temporary file, and get the amount of free space afterwards.
>
>I disagree: this is not reliable. Another user or process may increase or decrease the free disk space in the meantime. Unless I create a thousand small temp files, and round to the nearest power of 2...
>
Disclaimer: I consider George Tasker to be technically reliable, and a reasonably good friend even though we've never met face to face, so I'm not completely unbiased.
Let me suggest you trust George; his recommendation of the API is spot on, and his recommendation on writing a small file and checking it's actual disk space consumption is dead on, too; with NTFS, or FAT systems with DriveSpace installed, you have the issues of sub-cluster file space allocation and automatic compression. In RAID arrays, the unit of allocation is most likely a multiple of the base space allocation unit (min NTFS partition cluster size) * (number of RAID spindles - 1) is common if NTFS compression is not used, and OBTW, compression and sub-cluster allocation is controlled at the file or folder level so the rules aren't consistent. The API call will return the correct base space allocation unit of the logical volume.
Maybe familiarizing yourself with Windows internals would be a worthwhile thing to work towards.