Visual Basic WMI System Services
Obtaining System BIOS Information using WMI
     
Posted:   Monday March 25, 2002
Updated:   Monday November 28, 2011
     
Applies to:   VB5, VB6
Developed with:   VB6, Windows XP
OS restrictions:   Windows NT, 2000, XP. See Prerequisites below.
Author:   VBnet - Randy Birch
     

Related:  

Win32_BaseBoard: WMI Baseboard (Motherboard) Info
Win32_BIOS: WMI System BIOS Information

Win32_Processor: WMI Processor Information
Win32_CacheMemory: WMI System Cache Memory Info
Win32_TemperatureProbe: WMI Temperature Probe Info
     
 Prerequisites
Windows Script Host is built into Microsoft Windows 98, 2000, ME and XP. If you are running Windows 95 or NT4, you can download Windows Script Host from the Microsoft Windows Script Technologies Web site at http://msdn.microsoft.com/scripting/. Some information is not returned on non-NT-based systems.

A reference set in Projects / References to the Microsoft WMI Scripting Library.


The Win32_BIOS WMI class represents the attributes of the computer system's basic input/output services (BIOS) that are installed on the computer. The quality and amount of information returned may differ between machines.

This demo and illustration only show some of the available information from the class. For a complete listing see the table in the Comments section below. Note that some systems may not return information in all class properties.

 BAS Module Code
None.

 Form Code
To a form add a command button (Command1) and a listview (Listview1). Set a reference in Projects / References to the Microsoft WMI Scripting Library, and add the following to the form:

Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce 
'               or publish this code on any web site,
'               online service, or distribute as source 
'               on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'listview column auto-resizing
Private Const LVM_FIRST As Long = &H1000
Private Const LVM_SETCOLUMNWIDTH As Long = (LVM_FIRST + 30)
Private Const LVSCW_AUTOSIZE As Long = -1
Private Const LVSCW_AUTOSIZE_USEHEADER As Long = -2

Private Declare Function SendMessage Lib "user32" _
   Alias "SendMessageA" _
  (ByVal hwnd As Long, _
   ByVal wMsg As Long, _
   ByVal wParam As Long, _
   lParam As Any) As Long


Private Sub Form_Load()

   With ListView1
      .ListItems.Clear
      .ColumnHeaders.Clear
      .ColumnHeaders.Add , , "WMI Property"
      .ColumnHeaders.Add , , "Value(s)"
      .View = lvwReport
      .Sorted = False
   End With
   
   Command1.Caption = "BIOS Info"

End Sub


Private Sub Command1_Click()

   ListView1.ListItems.Clear
   Call wmiBiosInfo
   Call lvAutosizeControl(ListView1)
   
End Sub


Private Sub lvAutosizeControl(lv As ListView)

   Dim col2adjust As Long

  '/* Size each column based on the maximum of
  '/* EITHER the columnheader text width, or,
  '/* if the items below it are wider, the
  '/* widest list item in the column
   For col2adjust = 0 To lv.ColumnHeaders.Count - 1
   
      Call SendMessage(lv.hwnd, _
                       LVM_SETCOLUMNWIDTH, _
                       col2adjust, _
                       ByVal LVSCW_AUTOSIZE_USEHEADER)

   Next
   
End Sub


Private Sub wmiBiosInfo()
      
   Dim BiosSet As SWbemObjectSet
   Dim bios As SWbemObject
   Dim itmx As ListItem
   Dim cnt As Long
   Dim msg As String
   
   Set BiosSet = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
                                      InstancesOf("Win32_BIOS")
   
   On Local Error Resume Next
   
   For Each bios In BiosSet
   
      Set itmx = ListView1.ListItems.Add(, , "PrimaryBIOS")
      itmx.SubItems(1) = bios.PrimaryBIOS
            
      Set itmx = ListView1.ListItems.Add(, , "Status")
      itmx.SubItems(1) = bios.Status
      
      For cnt = LBound(bios.BIOSVersion) To UBound(bios.BIOSVersion)
         Set itmx = ListView1.ListItems.Add(, , IIf(cnt = 0, "BIOSVersion strings", ""))
         itmx.SubItems(1) = bios.BIOSVersion(cnt)
      Next
      
      Set itmx = ListView1.ListItems.Add(, , "Caption")
      itmx.SubItems(1) = bios.Caption
      
      Set itmx = ListView1.ListItems.Add(, , "Description")
      itmx.SubItems(1) = bios.Description
      
      Set itmx = ListView1.ListItems.Add(, , "Name")
      itmx.SubItems(1) = bios.Name

      Set itmx = ListView1.ListItems.Add(, , "Manufacturer")
      itmx.SubItems(1) = bios.Manufacturer

      Set itmx = ListView1.ListItems.Add(, , "ReleaseDate")
      itmx.SubItems(1) = bios.ReleaseDate

      Set itmx = ListView1.ListItems.Add(, , "SerialNumber")
      itmx.SubItems(1) = bios.SerialNumber

      Set itmx = ListView1.ListItems.Add(, , "SMBIOSBIOSVersion")
      itmx.SubItems(1) = bios.SMBIOSBIOSVersion
      
      Set itmx = ListView1.ListItems.Add(, , "SMBIOSMajorVersion")
      itmx.SubItems(1) = bios.SMBIOSMajorVersion
      
      Set itmx = ListView1.ListItems.Add(, , "SMBIOSMinorVersion")
      itmx.SubItems(1) = bios.SMBIOSMinorVersion

      Set itmx = ListView1.ListItems.Add(, , "SMBIOSPresent")
      itmx.SubItems(1) = bios.SMBIOSPresent
      
      Set itmx = ListView1.ListItems.Add(, , "SoftwareElementID")
      itmx.SubItems(1) = bios.SoftwareElementID
      
      Set itmx = ListView1.ListItems.Add(, , "SoftwareElementState")
      Select Case bios.SoftwareElementState
         Case 0: msg = "deployable"
         Case 1: msg = "installable"
         Case 2: msg = "executable"
         Case 3: msg = "running"
      End Select
      itmx.SubItems(1) = msg
      
      Set itmx = ListView1.ListItems.Add(, , "Version")
      itmx.SubItems(1) = bios.Version

      Set itmx = ListView1.ListItems.Add(, , "InstallableLanguages")
      itmx.SubItems(1) = bios.InstallableLanguages

      Set itmx = ListView1.ListItems.Add(, , "CurrentLanguage")
      itmx.SubItems(1) = bios.CurrentLanguage
        
      For cnt = LBound(bios.ListOfLanguages) To UBound(bios.ListOfLanguages)
      
         Set itmx = ListView1.ListItems.Add(, , IIf(cnt = 0, "ListOfLanguages", ""))
         itmx.SubItems(1) = bios.ListOfLanguages(cnt)
         
      Next cnt

      For cnt = LBound(bios.BiosCharacteristics) To UBound(bios.BiosCharacteristics)
      
         Set itmx = ListView1.ListItems.Add(, , IIf(cnt = 0, "BIOS Characteristics", ""))
      
         Select Case bios.BiosCharacteristics(cnt)
            Case 0: msg = "reserved"
            Case 1: msg = "reserved"
            Case 2: msg = "unknown"
            Case 3: msg = "BIOS characteristics not supported"
            Case 4: msg = "ISA supported"
            Case 5: msg = "MCA supported"
            Case 6: msg = "EISA supported"
            Case 7: msg = "PCI supported"
            Case 8: msg = "PC Card (PCMCIA) supported"
            Case 9: msg = "Plug and Play supported"
            Case 10: msg = "APM is supported"
            Case 11: msg = "BIOS upgradable (Flash)"
            Case 12: msg = "BIOS shadowing allowed"
            Case 13: msg = "VL-VESA supported"
            Case 14: msg = "ESCD support available"
            Case 15: msg = "Boot from CD supported"
            Case 16: msg = "Selectable boot supported"
            Case 17: msg = "BIOS ROM socketed"
            Case 18: msg = "Boot from PC card (PCMCIA) supported"
            Case 19: msg = "EDD (Enhanced Disk Drive) specification supported"
            Case 20: msg = "Int 13h, Japanese Floppy for NEC 9800 1.2mb (3.5, 1k b/s, 360 RPM) supported"
            Case 21: msg = "Int 13h, Japanese Floppy for Toshiba 1.2mb (3.5, 360 RPM) supported"
            Case 22: msg = "Int 13h, 5.25 / 360 KB floppy services supported"
            Case 23: msg = "Int 13h, 5.25 /1.2MB floppy services supported"
            Case 24: msg = "Int 13h 3.5 / 720 KB floppy services supported"
            Case 25: msg = "Int 13h, 3.5 / 2.88 MB floppy services supported"
            Case 26: msg = "Int 5h, print screen service supported"
            Case 27: msg = "Int 9h, 8042 keyboard services supported"
            Case 28: msg = "Int 14h, serial services supported"
            Case 29: msg = "Int 17h, printer services supported"
            Case 30: msg = "Int 10h, CGA/Mono video aervices supported"
            Case 31: msg = "NEC PC-98"
            Case 32: msg = "ACPI supported"
            Case 33: msg = "USB Legacy supported"
            Case 34: msg = "AGP supported"
            Case 35: msg = "I2O boot supported"
            Case 36: msg = "LS-120 boot supported"
            Case 37: msg = "ATAPI ZIP drive boot supported"
            Case 38: msg = "1394 boot supported"
            Case 39: msg = "Smart battery supported"
         End Select
         
         itmx.SubItems(1) = msg
         
      Next  'For cnt
      
   Next  'For Each bios

End Sub
 Comments
All information returned in the Win32_BIOS class (note that some systems may not return information in all class properties):
   
uint16 BiosCharacteristics[]
string BIOSVersion[]
string BuildNumber
string Caption
string CodeSet
string CurrentLanguage
string Description
string IdentificationCode
uint16 InstallableLanguages
datetime InstallDate
string LanguageEdition
String ListOfLanguages[]
string Manufacturer
string Name
string OtherTargetOS
boolean PrimaryBIOS
datetime ReleaseDate
string SerialNumber
string SMBIOSBIOSVersion
uint16 SMBIOSMajorVersion
uint16 SMBIOSMinorVersion
boolean SMBIOSPresent
string SoftwareElementID
uint16 SoftwareElementState
string Status
uint16 TargetOperatingSystem
string Version

 
 

PayPal Link
Make payments with PayPal - it's fast, free and secure!

 
 
 
 

Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved.
Terms of Use  |  Your Privacy

 

Hit Counter