views:

555

answers:

3

I am using WMI to query some properties disk drive. Does WMI read this information from the Drive itself or does it query the registry? How do I read the properties directly from the drive?

+1  A: 

The Win32_LogicalDisk Class must query the actual drive. I use it in powershell to show drive usage, which is not contained in the registry.

nabiy
+1  A: 

It doesn't have to be a single source. If a property of a WMi class has the MappingStrings qualifier, you can find the source of the property there. For example:

Win32_LogicalDisk.VolumeName - Win32API|File System Functions|GetVolumeInformation

Win32_LogicalDisk.MediaType - Win32API|Device Input and Output Functions|DeviceIoControl

Win32_LogicalDisk.NumberOfBlocks - MIB.IETF|HOST-RESOURCES-MIB.hrStorageSize

So it seems that it is mostly Win32 API and MIB

Uros Calakovic
+1  A: 

WMI queries the drive directly. In particular, the Win32_DiskDrive and Win32_LogicalDisk classes will query various properties about the drive. DiskDrive queries physical properties and configurations, whereas LogicalDisk queries volumes and partitions on the drive itself (like C:, etc). Not all WMI properties will be set for a particular drive; the drive may not support certain ones.

Scriptomatic, a Microsoft utility, can write up a quick script to pull all the properties for each class if you wanted to check it out, along with anything else WMI-related you might wish for. And it'll even do it in Perl!

romandas