SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 2 - WMI Programming with Visual Basic.NET: Tip...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

WMI Programming with Visual Basic.NET: Tips and Tricks
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2005-07-19

    Table of Contents:
  • WMI Programming with Visual Basic.NET: Tips and Tricks
  • Retrieving all properties of a WMI class without knowing their names
  • How does the program work?
  • How can we extend the above program to work with all objects?
  • How does this program work?

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    WMI Programming with Visual Basic.NET: Tips and Tricks - Retrieving all properties of a WMI class without knowing their names


    (Page 2 of 5 )

    In all of my previous parts of this series, I specified the properties I wanted to display manually. In order to do that, we should check with the WMI SDK documentation to get the full list of properties (and of course descriptions) of a particular WMI class. Now, is there any way to display all the properties at one time?

    The answer is yes. We do have a way to display all the properties (along with values) of almost any WMI class dynamically. Before we implement it practically, I need to introduce two of the new classes of the “System.Management” namespace:

    • PropertyDataCollection
    • PropertyData

    Using the “Properties” property of the “ManagementObject” class, we transfer all properties (along with values) to an object reference of type “PropertyDataCollection”. We extract each and every property of information from “PropertyDataCollection” by using “PropertyData”.  The following program illustrates the same. 

    DimdtAsNewDataTable

            dt.Columns.Add("Name")

            dt.Columns.Add("Value")

           DimdiskAsNewManagementObject("Win32_LogicalDisk.deviceid='c:'")

           DimdiskPropertiesAsPropertyDataCollection = disk.Properties

           DimdiskPropertyAsPropertyData

           ForEachdiskPropertyIndiskProperties

               DimdrAsDataRow = dt.NewRow

                dr("Name") = diskProperty.Name

                dr("Value") = diskProperty.Value

                dt.Rows.Add(dr)

           NextdiskProperty

            dt.AcceptChanges()

           Me.DataGrid1.DataSource = dt

    The above program gets all of the properties along with their values into a data table, and finally gets them displayed through a data grid.  The next section gives you a detailed explanation of the above program.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


     

    VISUAL BASIC.NET ARTICLES

    - Movement and Player Statistics in a VB.NET T...
    - Creating and Drawing a Game Map in VB.NET
    - Working with Classes and Properties for Game...
    - Working with Loops, Arrays, and Collections ...
    - Learning Loops in VB.NET for Game Development
    - Learning VB.NET: Working with Variables, Con...
    - The Basics of VB.NET Through Text Game Devel...
    - Learning VB.NET Through Text Game Development
    - Types of Operators in Visual Basic
    - Operators
    - Understanding Custom Events using Visual Bas...
    - Polymorphism using Abstract Classes in Visua...
    - Shadowing using Shadows in Visual Basic.NET ...
    - Overloading and Overriding in Visual Basic.N...
    - More on Controlling Windows Fax Services Usi...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway