开发者

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

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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜