I know you can use a combination of GetLogicalDrives() and GetDiskFreeSpaceEx() to get the list of drives and their sizes. I’ve been using GetDiskFreeSpaceEx() with no problem but when I try to use GetLogicalDrives() I ran into a problem: I don’t want to have to check each possible letter to see whether it exists or not before passing it to GetDiskFreeSpaceEx().
Is there a simpler way to get the list of drives (disk) on the system and what their sizes are? I am using C, on Windows.
I want to make something clear, I KNOW it might be easier using C# and WMI, I have no interest on that so please do not post that as a possible solution. If you want to point to how is done in C and WMI, go for it. NO C++ or C# thanks! (like someone did in my previous question)
GetLogicalDrives() is the system-provided API for that. A simple for() loop will translate its result into drive letters, like this:
And if you’re not satisfied with the level of service that Stack Overflow provides, feel free to ask for your money back.