16MB Compact Flash Card states wrong geometry data (half size only) - How to determine capacity properly?

Hi everybody,

I have a very strange phenomenon here. I took two CF cards, one 16MB, the other 512MB and tried to determine their storage capacity programmatically. To do so, I used two different methods (all experiments done on Windows 2000 with latest updates):

1) Determine size of logical drive with GetDiskFreeSpace and GetVolumeInformation.
This delivers the proper size on both cards but obviously only when the cards are properly formatted.

2) Open a handle to the physical device with CreateFile, then use DeviceIoControl with the control code IOCTL_DISK_GET_DRIVE_GEOMETRY. This should work as long as Windows can see a card in the card reader.
However, for this method, the 16MB card returns a structure which would outline an 8MB card!
I did some searching on the website and found some WMI script for enumerating all the hard discs in a computer. This delivers the wrong value of 8MB as well!

My first assumption was that the card is broken somehow, but I tried another card and it shows the same effect. Both cards are completely okay, my Digicam detects them as 16MB card as well and it is possible to use the whole 16MB for data, too.

So here are my questions:
Is this behaviour common? How do I determine the proper size? (My digicam can, so should Windows!) And is there another, more reliable method of determining the card size regardless of a working file system on it?

I am pretty clueless at present, any ideas and suggestions are welcome :D

Movie Stars

Solution: 16MB Compact Flash Card states wrong geometry data (half size only) - How to determine capacity properly?

PAQed with points refunded (500)

modulo
Community Support Moderator