Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am, admittedly, very new to the whole WMI "thing". This "thing" is quite overwhelming and I'm not finding an answer to the question that I have at this point. I've found the best information for the drives in my system using Win32_DiskDrive. The PNPDeviceID field even seems to encode the Port # that the particular SATA drive is connected to for its HBA. However, how can I link a particular drive to its HBA? None of the fields in the Win32_DiskDrive class seem to contain this information. I know that it's attached to the Intel HBA on my MB. For example, the PNPDeviceID field for my boot disk:

PNPDeviceID IDE\DISKWDC_WD2500AAKS-00L9A0___________________0956____\6&C07A520&0&0.1.0

It's interesting to me that the WMI classes identify this drive as an IDE drive since it's SATA, but I don't much care about that. What's more interesting is, how do I map this drive to its HBA? Is there a WMI class that has the particular field I'm interested in?

As an additional question, in the above text, how do I interpret the values after that second \ character?

share|improve this question

migrated from stackoverflow.com Nov 15 '11 at 23:59

This question came from our site for professional and enthusiast programmers.

3  
Migrators, please explain how correct use of the Device Manager API belongs on the "hardware and power users" site! –  Ben Voigt Nov 16 '11 at 0:24

2 Answers 2

You have to look at the Parent. I'm not sure how that's exposed in WMI, but the device manager API provides CM_Get_Parent.

share|improve this answer
    
thank you for the pointers. As I mentioned, I'm quite new to this. Can you provide an example of how to make use of this? I'm looking on whatever I've been able to find thus far, but I'm not entirely sure of all I need. It looks like a foregone conclusion that I'm going to have to P/Invoke a good deal of stuff. –  Andrew Falanga Nov 15 '11 at 18:30

CIM_ControlledBy should give you the controller as Antecedent when the Dependent is the instance of Win32_PNPEntity with the given PNPDeviceID, i.e.

select DeviceID from Win32_PNPEntity where PNPDeviceID = '...'
associators of {Win32_PNPEntity.DeviceId = '...'} where AssocClass = CIM_ControlledBy
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.