Question

We're using a small self-made windows-based tool to write OS, Images and a FAT partition containing data on SD cards that will then be used in embedded devices as boot medium and data storage.

I'm currently using IOCTL_DISK_GET_DRIVE_GEOMETRY to get the size of an SD card. However, due to the limitations of the CHS format it's not the real size of the SD card. This is not a big issue, since only a few sectors are wasted, however it would be nice to use all of the available space on the card.

Is there a better way to get the size of the drive? Remember, I'm not interested in the partition size. I need the total number of bytes (or sectors) that I can access on the SD card. Also, the drive might not be formated (correctly - my tool creates "too small" partitions) and formating it with windows first is not an option.

Fozi

Was it helpful?

Solution

You can try using IOCTL_DISK_GET_LENGTH_INFO. However, this IOCTL was added in Windows XP and later OSes.
http://msdn.microsoft.com/en-us/library/aa365178(VS.85).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top