Visual Basic.NET
  Home arrow Visual Basic.NET arrow Page 2 - Getting Hardware Information Using Visual ...
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 
Moblin 
JMSL Numerical Library 
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

Getting Hardware Information Using Visual Basic.NET and VBScript
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 16
    2006-01-25

    Table of Contents:
  • Getting Hardware Information Using Visual Basic.NET and VBScript
  • The class Win32 OnBoardDevice in detail
  • The class Win32_Processor in detail
  • Digging further into the motherboard's details

  • 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


    Getting Hardware Information Using Visual Basic.NET and VBScript - The class Win32 OnBoardDevice in detail


    (Page 2 of 4 )

    In the previous section, I touched on only some of the most important properties from the existing WMI class (Win32_OnBoardDevice); had I done otherwise, it would have made the program too long. The program above will list the description, device type and tag properties. You can further extend the program with several other properties available in the “Win32_OnBoardDevice” class. You can even refer to MSDN online for further properties.

    Now, let us go into the details of the properties I mentioned in the previous section.

    Description: This property gives you a better explanation of the object.

    Device Type: In general, there will be many types of devices “OnBoard.” The devices include Video, SCSI controller, Ethernet (especially for LAN), and so on. The “Device Type” property explains the type of device being represented. The following is the table extracted from MSDN to provide you with an explanation of those values returned by “Device Type.”

    Value

    Meaning

    1

    Other

    2

    Unknown

    3

    Video

    4

    SCSI Controller

    5

    Ethernet

    6

    Token Ring

    7

    Sound

      

    Enabled: This property specifies whether the device is enabled to work or not. Sometimes, it also depends on hardware settings or configuration.

    Tag: This property gives you the unique identifier of the onboard device available for your system.

    Listing the processors available

    In previous sections, we have seen only “On Board Devices.” Now, let us go through the information related to the processors existing in your system. The following VB.NET code should support retrieving some minimum information about processors available on your system.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                Dim searcher As New ManagementObjectSearcher( _
                    "root\CIMV2", _
                    "SELECT * FROM Win32_Processor")
                Dim dt As DataTable = globals.getProcessorStructure
                For Each queryObj As ManagementObject In searcher.Get()
                    globals.addProcessorDevice(dt, Convert.ToString(queryObj("Availability")), queryObj("Caption"), Convert.ToString(queryObj("CpuStatus")), Convert.ToString(queryObj("CurrentClockSpeed")), queryObj("DeviceID"), Convert.ToString(queryObj("Level")), queryObj("Name"), queryObj("ProcessorId"), Convert.ToString(queryObj("ProcessorType")), queryObj("SystemName"))
                Next
                Me.DataGrid1.DataSource = dt
            Catch err As ManagementException
                MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
            End Try
        End Sub

    You can achieve the same thing with VBScript as follows:

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery( _
        "SELECT * FROM Win32_Processor",,48)
    For Each objItem in colItems
        Wscript.Echo "Availability: " & objItem.Availability
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "CpuStatus: " & objItem.CpuStatus
        Wscript.Echo "CurrentClockSpeed: " & objItem.CurrentClockSpeed
        Wscript.Echo "DeviceID: " & objItem.DeviceID
        Wscript.Echo "Level: " & objItem.Level
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "ProcessorId: " & objItem.ProcessorId
        Wscript.Echo "ProcessorType: " & objItem.ProcessorType
        Wscript.Echo "SystemName: " & objItem.SystemName
    Next

    More Visual Basic.NET Articles
    More By Jagadish Chaterjee


       · Hello guys, another interesting article on WMI with VB.NET and VBScript. Enjoy and...
       · The articles do not give the code for addONBoardDevices and addProcessorDevice ....
       · Hi, I already provided the code in the downloadable. Please download the zip...
     

    VISUAL BASIC.NET ARTICLES

    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...
    - Creating and Drawing a Game Map in VB.NET (F...
    - 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 ...





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