Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to get the WMI property description??

How to get the WMI property description??

Scheduled Pinned Locked Moved Visual Basic
tutorialcsharpbeta-testingquestioncode-review
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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! :)

    D P 2 Replies Last reply
    0
    • L Lost User

      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! :)

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • L Lost User

        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! :)

        P Offline
        P Offline
        progload
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups