WMI and the difference between memory cards and USB drives
-
I've noticed in Device Manager that the Mass Storage Devices for the multi-card readers I own have a "Bus reported device description" of "Mass Storage Device" -- a generic name -- but the one for the USB drive instead has the description of the device name. Is this at all significant? And where does the "Bus reported device description" come from?
Educated guesswork, don't quote me on this :) : Real hard disk devices have firmware, and it's the firmware that reports this. (it will usually correspond to the 'friendly device name', I think). Disk drive producers will often include free utilities (such as some backup crapware), which will only run on their kit. The software has to check if their kit is connected, and it will do that by checking this field. Often, firmware must also be updated, usually using specific IOCTLs, and the firmware update utilities must be sure they don't clobber some other manufacturer's. This field may help in checking the origin of the kit before they issue their 'zap and destroy' IOCTLs. Some USB disk assemblies also offer firmware RAID configurations, and this may help their raid configuration utilities in determining the command set to configure them. A storage card has no firmware, and so cannot report anything here (there may be exceptions, but I haven't come across any). If there's anything firmware worth reporting, it will be at the composite device level. Anyway, a storage card can only report anything when it's inserted, so this probably wouldn't serve your purpose.
-
Educated guesswork, don't quote me on this :) : Real hard disk devices have firmware, and it's the firmware that reports this. (it will usually correspond to the 'friendly device name', I think). Disk drive producers will often include free utilities (such as some backup crapware), which will only run on their kit. The software has to check if their kit is connected, and it will do that by checking this field. Often, firmware must also be updated, usually using specific IOCTLs, and the firmware update utilities must be sure they don't clobber some other manufacturer's. This field may help in checking the origin of the kit before they issue their 'zap and destroy' IOCTLs. Some USB disk assemblies also offer firmware RAID configurations, and this may help their raid configuration utilities in determining the command set to configure them. A storage card has no firmware, and so cannot report anything here (there may be exceptions, but I haven't come across any). If there's anything firmware worth reporting, it will be at the composite device level. Anyway, a storage card can only report anything when it's inserted, so this probably wouldn't serve your purpose.
Actually it kind of would serve my purpose -- I just want to determine whether a logical disk is hosted by a card reader, or is hosted by a USB drive. If I could determine the 'bus reported' description for any given USB Mass Storage Device.. but I don't know how to do that. Can you help?
-
Actually it kind of would serve my purpose -- I just want to determine whether a logical disk is hosted by a card reader, or is hosted by a USB drive. If I could determine the 'bus reported' description for any given USB Mass Storage Device.. but I don't know how to do that. Can you help?
I'll dig around a bit, don't expect anything today, bedtime coming soon in my timezone :zzz:
-
I'll dig around a bit, don't expect anything today, bedtime coming soon in my timezone :zzz:
Based on the devices that I have, I figured out that you can expect a USB Flash Drive to have PDCAP_D2_SUPPORTED under "Power data" in Device Manager, but not a memory card. So I used a PInvoke to DevicePowerEnumDevices in PowrProf.dll ( http://msdn.microsoft.com/en-us/library/aa372681(VS.85).aspx[^] ). That allowed me to filter by the device name in Win32_DiskDrive.Model and the PDCAP_D2_SUPPORTED flag.
-
Based on the devices that I have, I figured out that you can expect a USB Flash Drive to have PDCAP_D2_SUPPORTED under "Power data" in Device Manager, but not a memory card. So I used a PInvoke to DevicePowerEnumDevices in PowrProf.dll ( http://msdn.microsoft.com/en-us/library/aa372681(VS.85).aspx[^] ). That allowed me to filter by the device name in Win32_DiskDrive.Model and the PDCAP_D2_SUPPORTED flag.
Sounds reasonable. This would probably correspond to a 'spin-down' on USB disks, which makes no sense on flash cards (they are only required to support D0 and D3, fully ON and fully OFF). Wonder what an SSD would have in this case?
-
Sounds reasonable. This would probably correspond to a 'spin-down' on USB disks, which makes no sense on flash cards (they are only required to support D0 and D3, fully ON and fully OFF). Wonder what an SSD would have in this case?
Actually, this doesn't seem to be working.. I thought it was, but I must have been mistaken. The internal card readers don't support D2, but the external card readers do.
-
Sounds reasonable. This would probably correspond to a 'spin-down' on USB disks, which makes no sense on flash cards (they are only required to support D0 and D3, fully ON and fully OFF). Wonder what an SSD would have in this case?
I figured out what I did wrong --- you have to do a check on the Logical Disk name, not the Disk Drive name. The Disk Drive for the card reader supports more power states, and the Portable Device (listed in Device Manager) supports even more, including D1.
-
Sounds reasonable. This would probably correspond to a 'spin-down' on USB disks, which makes no sense on flash cards (they are only required to support D0 and D3, fully ON and fully OFF). Wonder what an SSD would have in this case?
Except that only seems to work for one flash drive I have and not another. I'll continue to investigate that.
-
Sounds reasonable. This would probably correspond to a 'spin-down' on USB disks, which makes no sense on flash cards (they are only required to support D0 and D3, fully ON and fully OFF). Wonder what an SSD would have in this case?
It was my error; the problem was it didn't find a drive with that drive letter because it was referring to the Portable Device, and thats listed by the Volume name if there is one. But I finally found something that works! If you enumerate the hardware ID strings for the devices that support D2, the only ones that show up are the ones for flash drives. The memory cards are enumerated I think, but a query for the hardware ID returns an empty string. So you have to find the PnPEntity associated with the DiskDrive, and take the first indexed HardwareID. No problems with this so far..
-
It was my error; the problem was it didn't find a drive with that drive letter because it was referring to the Portable Device, and thats listed by the Volume name if there is one. But I finally found something that works! If you enumerate the hardware ID strings for the devices that support D2, the only ones that show up are the ones for flash drives. The memory cards are enumerated I think, but a query for the hardware ID returns an empty string. So you have to find the PnPEntity associated with the DiskDrive, and take the first indexed HardwareID. No problems with this so far..
Just so people reading this know... it turns out the original solution I found is working again. I don't know if it was a glitch in how my system was reporting the information or whether the second, more thorough method is just more fool-proof. I'm getting the power data through setupapi.dll rather than through powerprof.dll though, since I'm trying to move away from WMI.