Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve SD Card serial number on Windows XP/Vista/7?

Tags:

winapi

sd-card

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.

like image 365
Head Geek Avatar asked Dec 06 '25 14:12

Head Geek


1 Answers

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

  • SetupDiGetClassDevs
  • SetupDiEnumDeviceInfo
  • SetupDiEnumDeviceInterfaces
like image 59
Mike Dinescu Avatar answered Dec 08 '25 04:12

Mike Dinescu