Wednesday, January 11, 2006

"Using Reflection in C# to print WMI object properties"

Saveen Reddy's blog : Using Reflection in C# to print WMI object properties

"Scenario

You need to dump all the properties in a collection of WMI objects, but you don't want to manually use WriteLine() for each property because it's dull work.

Here is a link to code sample you want to avoid is : this post

What you want

A function that takes collection of WMI objects and prints whatever properties are available.

Using Reflection to get what we want

In a previous post, I wrote about using Mgmtclassgen.exe to generate strongly typed WMI classes. Combine that with System.Reflection and you have an easy way to dump any collection of WMI objects....

..."

This looks like a cool trick to help when working with WMI.

One "problem" with WMI is that there's just SO much information. It really helps seeing the real/live results for a given WMI object. That's were this code snip will help...

2 comments:

  1. If you're not limited to C#, the easier route for both WMI and objects in general is to use Monad since it does all the reflection/display logic for you for arbitrary objects.

    ReplyDelete
  2. Nice...

    I'm waiting for Monad to RTM before I play with it but in reading I've done, it sure looks cool.

    ReplyDelete

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...