Further search in my very educational WMI escapade. Each WMI class returns a set of properties, and within those properties are values. Some of these values are numerical, which mean something, but without looking them up, you really don't know what they mean. For example, for the Win32_Processor class, the "Architecture" property returns a particular number, and the possible values are below and found on MSDN Here:
_____________________________________
Architecture
Data type: uint16
Access type: Read-only
Processor architecture that the platform uses.
Value Meaning
0 x86
1 MIPS
2 Alpha
3 PowerPC
6 Intel Itanium Processor Family (IPF)
_____________________________________
So a value of "0" would mean "x86". Now I would like to "look up" the value of the "0" in some resource, in order to return the associated text, like a regular enumeration, but I am not quite sure where to get this kind of info. I really do not want to go class by class on MSDN in order to create this resource, as it will be VERY time consuming. Anyone know of any resources that already contain this? Like in some sort of text file or XML file?????
If anyone can find this you can expect a big fat rating point from me!! (I only have the power of one)
Last edited by gigemboy; Feb 18th, 2006 at 04:06 AM.
Nope, it doesnt. The properties you tried return regular information anyway. Try it with the "Architecture" property... it returns a number. Several other properties are like that as well (like 5 or 6+ in the Processor class alone), and its like that for every WMI class. Thats why I don't want to go in and make these lookup tables or enumerations for each class, because its going to take a while... wonder if someone out there in the world has done this already in some sort of easily obtainable resource...
Last edited by gigemboy; Feb 18th, 2006 at 04:52 AM.
Its all listed in the documentation for each WMI class, with the lookup values, but I cant seem to find any place that has just those lookup values by themselves all centralized in once place...
I came across the .GetRelationship and .GetRelated. I'm too tired to think straight and can only imagine how tired you are but Im heading off to bed. I'll check back in the morning to see hoow its going.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Mgmtclassgen.exe is a tool included with Visual Studio that I even had on my computer and didn't know about. It is a command line utility that you can use to generate a VB or C# wrapper class for any WMI class you want! And the best part of it?? The Enumeration values are all built in when you generate the file!!
*dancing around*
Last edited by gigemboy; Feb 19th, 2006 at 10:36 PM.
Re: [RESOLVED] WMI Enumeration Values for each Class?
All they use are public Enumerations, and return the name associated with the value in the properties that require it, just like I was going to do it (just read the generated code, havent actually tested it myself either)
Re: [RESOLVED] WMI Enumeration Values for each Class?
I tried it with the generated processor class, there are a couple errors on the variables, but real easy to fix. It is displaying the properties nice However I ran into another problem I'm going to have. Now I have to find some way to loop through all properties of each class instead of hard coding them (since the names are going to differ per class). Im guessing the only option for this is reflection???
Re: [RESOLVED] WMI Enumeration Values for each Class?
Thats what I was thinking, but there isnt any property collection when you use that class. Before, you could loop through the properties because it was part of the managementobject class, but when you change it into the new generated processor class, you dont have any type of propertycollection anymore... at least as far as I can see.... but you do have access to all the properties, and all return the desired results, but you have to hard code them in, but since Im going to be working with MOST of the WMI classes (150-200 of them hehe), I really need to loop all properties regardless of the class, which led me to reflection, as that is usually how it is done with any regular class...
Below is the attached Win32_Processor generated class... if you want to play with it
Here is how I tested it:
VB Code:
Dim query As New SelectQuery("Win32_processor")
Dim search As New ManagementObjectSearcher(query)
Dim info As ManagementObject
For Each info In search.Get
Dim MyProcessor As New ROOT.CIMV2.win32.processor(info)
Re: [RESOLVED] WMI Enumeration Values for each Class?
Originally Posted by RobDog888
Thats alot of code but with the new issues would it be better to take the Enums and write your own lookup function?
Thats what I was thinking also, which I may in fact do since I was almost there in the first place.. just wanted to make sure I wasn't overlooking something in the class...
Re: [RESOLVED] WMI Enumeration Values for each Class?
Well that certainly works, JM This is a perfect example of reflection in work, because I will even have to declare new instances of the classes by string as well since I won't know what type to instantiate until the user clicks on the particular class they want information for, which I know can be done also with reflection. Much better than hard coding in 150-200 classes in a case statement....