Friday, November 18, 2005

Management Strongly Typed Class Generator (Mgmtclassgen.exe)

Management Strongly Typed Class Generator (Mgmtclassgen.exe)

"The Management Strongly Typed Class Generator enables you to quickly generate an early-bound managed class for a specified Windows Management Instrumentation (WMI) class. The generated class simplifies the code you must write to access an instance of the WMI class."

Saveen Reddy points out the cool .Net utility called Mgmtclassgen.exe.

Mgmtclassgen will create a C#, VB, J# class for a given WMI Class. What's cool is that the class is also instrumented with description attributes about a given property.

Looks like this could make WMI easier and more approachable...

"mgmtclassgen Win32_LogicalDisk /l VB /p c:\disk.vb"

Here's a snip...


<Browsable(True), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), _
Description("The Compressed property indicates whether the logical " & _
"volume exists as a single compressed entity, such as a DoubleSpace" & _
"volume. If file based compression is supported (such as on NTFS), " & _
"this property will be FALSE."), _
TypeConverter(GetType(WMIValueTypeConverter))> _
Public ReadOnly Property Compressed() As Boolean
Get
If (curObj("Compressed") Is Nothing) Then
Return System.Convert.ToBoolean(0)
End If
Return CType(curObj("Compressed"), Boolean)
End Get
End Property

No comments: