SunQuest
 
       Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 3 - 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 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    WMI Programming with Visual Basic.NET: Tips and Tricks - How does the program work?


    (Page 3 of 5 )

    Let me explain the above program line by line. 

    DimdtAsNewDataTable

            dt.Columns.Add("Name")

            dt.Columns.Add("Value")

    The above set of statements prepare a data table (for storing all properties with their values) with only two columns, namely “Name” and “Value”. 

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

    The above statement retrieves only a single instance of the “Win32_LogicalDisk” class based on the filter ‘deviceID=c:’. This excludes the use of unnecessary objects of type “ManagementObjectCollection”, as we are working with only a single instance.

    DimdiskPropertiesAsPropertyDataCollection = disk.Properties

    The above statement retrieves all properties along with all values using “disk.Properties” and stores them in the “diskProperties” object.

           DimdiskPropertyAsPropertyData

    The above statement declares “diskProperty” to access each and every property from “diskProperties” collection.

    ForEachdiskPropertyIndiskProperties

               DimdrAsDataRow = dt.NewRow

                dr("Name") = diskProperty.Name

                dr("Value") = diskProperty.Value

                dt.Rows.Add(dr)

           NextdiskProperty

    The above loop iterates through each and every property existing in the “diskProperties” collection using “diskProperty” and assigns property information to a new individual data row, which finally gets added to the data table.

            dt.AcceptChanges()

    The above statement ensures that the data table is filled with all of the contents from memory.

           Me.DataGrid1.DataSource = dt

    The above statement displays all of the information available in the data table through a data grid.

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


     

    VISUAL BASIC.NET ARTICLES

    - 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...
    - Programmatically Controlling Windows Fax Ser...





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