|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Accessing nested Win32/CIM Classes, using System.Management namespprojects. When trying to access a nested class using the ManagementBaseObject.GetPropertyValue("PropertyName") method my programs always throw exceptions. I have also tried using the Indexer ManagementBaseObject["PropertyName"] and the same exception is raised. Here's an example of what I am trying to do: //Display the "Name" of a CIM_LogicalDevice class which is nested in a Win32_USBControllerDevice class ((ManagementBaseObject)usbConDev.GetPropertyValue("Dependent")).GetPropertyValue("Name").ToString(); The line above will cause an exception every time... I realize a lot is happening in one line, but you should be able to break it up into seperate shorter lines if you like. My problem is that GetPropertyValue & the Indexer both have a return type of "object". When trying to cast the returned object to a "ManagementBaseObject", "int" or anything else other than a string I get exceptions. Does anyone know a way around this? I tried using the GetType() method but it seemed to always return a "System.string" Any help would be greatly appreciated!! Alex |
|||||||||||||||||||||||