How to get the WMI property description??
-
How is it possible to retrieve the WMI property description field with VB 2005 / .net? Example: for the value
root\CIMV2:Win32_PerfRawData_SMTPSVC_SMTPServer\MessageBytesTotal
the Property Description is "The total number of bytes sent and received in messages." With this code I can get the value of "MessageBytesTotal", however how to get the description into a string variable? :confused:Dim mc As ManagementClass Dim menge As ManagementObjectCollection Dim mo As ManagementObject Dim strTmp As String Try mc = New ManagementClass("\\MeinServer\root\cimv2:Win32_PerfRawData_SMTPSVC_SMTPServer") menge = mc.GetInstances() For Each mo In menge strTmp = mo("MessageBytesTotal") Next mc.Dispose() Return strTmp Catch ex1 As Exception console.writeline (ex1.Message) End Try
Which code do I need to add to get success? I have tried this here, but it does not work:strTmp2 = mo("Description")
Thanks for any hint and feedback! :) -
How is it possible to retrieve the WMI property description field with VB 2005 / .net? Example: for the value
root\CIMV2:Win32_PerfRawData_SMTPSVC_SMTPServer\MessageBytesTotal
the Property Description is "The total number of bytes sent and received in messages." With this code I can get the value of "MessageBytesTotal", however how to get the description into a string variable? :confused:Dim mc As ManagementClass Dim menge As ManagementObjectCollection Dim mo As ManagementObject Dim strTmp As String Try mc = New ManagementClass("\\MeinServer\root\cimv2:Win32_PerfRawData_SMTPSVC_SMTPServer") menge = mc.GetInstances() For Each mo In menge strTmp = mo("MessageBytesTotal") Next mc.Dispose() Return strTmp Catch ex1 As Exception console.writeline (ex1.Message) End Try
Which code do I need to add to get success? I have tried this here, but it does not work:strTmp2 = mo("Description")
Thanks for any hint and feedback! :)AFAIK, there is no way to retrieve the property/method/event descriptions in WMI. You can retrieve the list of properties/methods, and their data types, but not the descriptions. The only place I know to get that information is in the MOF files that were used to compile the WBEM classes. It would involving parsing those file to get the info. I don't know of an API to do it for you. I could be wrong though...
Dave Kreskowiak Microsoft MVP - Visual Basic
-
How is it possible to retrieve the WMI property description field with VB 2005 / .net? Example: for the value
root\CIMV2:Win32_PerfRawData_SMTPSVC_SMTPServer\MessageBytesTotal
the Property Description is "The total number of bytes sent and received in messages." With this code I can get the value of "MessageBytesTotal", however how to get the description into a string variable? :confused:Dim mc As ManagementClass Dim menge As ManagementObjectCollection Dim mo As ManagementObject Dim strTmp As String Try mc = New ManagementClass("\\MeinServer\root\cimv2:Win32_PerfRawData_SMTPSVC_SMTPServer") menge = mc.GetInstances() For Each mo In menge strTmp = mo("MessageBytesTotal") Next mc.Dispose() Return strTmp Catch ex1 As Exception console.writeline (ex1.Message) End Try
Which code do I need to add to get success? I have tried this here, but it does not work:strTmp2 = mo("Description")
Thanks for any hint and feedback! :)If you are realy into a bit of work, you could generate your own managed class using mgmtclassgen.exe and just add your own custom property for it. Read on... for instructions: The following command generates a managed class from Win32_PerfRawData_SMTPSVC_SMTPServer mgmtclassgen.exe Win32_PerfRawData_SMTPSVC_SMTPServer /n root\cimv2 /l VB /p c:\SMTPServer.vb The tool writes the managed class to the source file at c:\SMTPServer.vb, using the ROOT.CIMV2.Win32 namespace. Add the file to your project. Add the following to SMTPServer.vb somewhere near "Public ReadOnly Property MessageBytesTotal()" (about line # 2509 in my file.): _ Public ReadOnly Property MessageBytesTotalDescription() As String Get Return "The total number of bytes sent and received in messages." End Get End Property And/Or whatever you want the property(s) to be.. And/Or Your own overloads ect.. Have fun.. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfmanagementstronglytypedclassgeneratormgmtclassgenexe.asp -- modified at 1:47 Friday 15th September, 2006