The IOCTL_DISK_GET_DRIVE_GEOMETRY example code of Microsoft gives the expected results for the hard disk.
The SD card is drive F: and has no file system. The card was previously written by an 8 bit microcontroller and file system is out of the question. In the windows explorer, the SD card size is displayed correctly as 1886 MB. However when I run the program I get 0.01 GB.
Is the example code correct? I slightly changed the original code, the changed one is here.
Can it be an issue with Mingw? I doubt, it works fine for the hard disk. It is mingw32 gcc 4.6.1 on WinXP SP2. The resulting program is run on Win7. I am using Linux and I have very limited access to native Win7.
How can I figure out the size of the SD card without file system?
As pointed out by Hans Passant, the IOCTL_DISK_GET_LENGTH_INFO should be passed to
DeviceIoControl.Everything works fine if the
CreateFileremarks concerning physical disks and volumes are followed. The resulting code is here.