views:

1348

answers:

1

There is a manufacturer's serial number on SD cards, and there are a number of pages on the 'net that describe how to retrieve it on various mobile devices (including this one). But I need to retrieve it under desktop versions of Windows, and the code that works for mobile versions of Windows doesn't seem to translate.

The question: how do you programmatically retrieve the SD card manufacturer's serial number from an SD card under desktop Windows?

EDIT: From what I gather, this can be done using the DeviceIoControl's IOCTL_SFFDISK_DEVICE_COMMAND to send command 10 from the SD Card specs, but it's unreliable -- it only works with certain non-USB card readers, and only with certain drivers for those readers. That makes it useless for our purposes. Maybe someone else can get some use from the information.

A: 

Well, you could do this using SetupDiXXX api calls (see this Code Project example) or if I'm not mistaken using WMI queries.

I'm not very versatile using WMI queries but I'm sure there's a ton of info on the net about it.

Using the SetupDiXXX methods you can query for present devices of a specific class (you would have to look up the device class for SD cards) and then enumerate through the devices present in the computer, reading the Manufacturer Serial number.

For reference on SetupDiXXX functions, see the following

Miky Dinescu
Thanks, but it looks like there's no way to do it reliably. I'm editing the question to explain what I've found.
Head Geek