Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


Windows Management Instrumentation (WMI) makes Windows extremely manageable using a single consistent, standards-based, extensible and object-orientated interface. WMI is the Microsoft implementation of Web-Based Enterprise Management (WBEM), an industry initiative to develop a standard technology for accessing management information in an enterprise environment. This initiative helps companies lower their total cost of ownership by enabling powerful management of systems, applications and devices.

Here is a simple demo of how to get processor information using WMI

Step-By-Step Example

- Create a standard exe project
- Add one command button and one listbox on the form1
- Add the following code in form1

Click here to copy the following block
'Download SDK from
'http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=afe41f46-e213-4cbf-9c5b-fbf236e0e875
'
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 Const LB_SETTABSTOPS = &H192

Private blInstalled   As Integer

Private Sub GetProcessorInformation(ByRef ctrlOut As ListBox)
  Dim wmiInstances  'As SWbemObjectSet
  Dim wmiInst  'As SWbemObject
  Dim Architecture  'As Integer
  Dim Availability  'As Integer
  Dim CpuStatus  'As Integer
  Dim Family  'As Integer
  Dim ProcessorType  'As Integer
  Dim StatusInfo  'As Integer
  Dim UpgradeMethod  'As Integer

  Set wmiInstances = GetObject("winmgmts:{impersonationLevel=impersonate}//").InstancesOf("Win32_Processor")
  On Error Resume Next
  For Each wmiInst In wmiInstances
    With ctrlOut
      .Clear
      Architecture = wmiInst.Achitecture
      Select Case Architecture
        Case Is = 0: Call .AddItem("Architecture :" & vbTab & "[ " & wmiInst.Architecture & " ] x86")
        Case Is = 1: Call .AddItem("Architecture :" & vbTab & "[ " & wmiInst.Architecture & " ] MIPS")
        Case Is = 2: Call .AddItem("Architecture :" & vbTab & "[ " & wmiInst.Architecture & " ] Alpha")
        Case Is = 3: Call .AddItem("Architecture :" & vbTab & "[ " & wmiInst.Architecture & " ] PowerPC")
        Case Is = 6: Call .AddItem("Architecture :" & vbTab & "[ " & wmiInst.Architecture & " ] ia64")
      End Select
      Availability = wmiInst.Availability
      Select Case Availability
        Case Is = 1: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Other")
        Case Is = 2: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Unknown")
        Case Is = 3: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Running or Full Power")
        Case Is = 4: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Warning")
        Case Is = 5: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] In Test")
        Case Is = 6: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Not Applicable")
        Case Is = 7: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Power Off")
        Case Is = 8: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Off Line")
        Case Is = 9: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Off Duty")
        Case Is = 10: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Degraded")
        Case Is = 11: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Not Installed")
        Case Is = 12: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Install Error")
        Case Is = 13: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Power Save - Unknown")
        Case Is = 14: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Power Save - Low Power Mode")
        Case Is = 15: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Power Save - Standby")
        Case Is = 16: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Power Cycle")
        Case Is = 17: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Power Save - Warning")
        Case Is = 18: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Paused")
        Case Is = 19: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Not Ready")
        Case Is = 20: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Not Configured")
        Case Is = 21: Call .AddItem("Availability :" & vbTab & "[ " & wmiInst.Availability & " ] Quiesced")
      End Select
      CpuStatus = wmiInst.CpuStatus
      Select Case CpuStatus
        Case Is = 0: Call .AddItem("CpuStatus :" & vbTab & "[ " & wmiInst.CpuStatus & " ] Unknown")
        Case Is = 1: Call .AddItem("CpuStatus :" & vbTab & "[ " & wmiInst.CpuStatus & " ] CPU Enabled")
        Case Is = 2: Call .AddItem("CpuStatus :" & vbTab & "[ " & wmiInst.CpuStatus & " ] CPU Disabled by User via BIOS Setup")
        Case Is = 3: Call .AddItem("CpuStatus :" & vbTab & "[ " & wmiInst.CpuStatus & " ] CPU Disabled By BIOS (POST Error)")
        Case Is = 4: Call .AddItem("CpuStatus :" & vbTab & "[ " & wmiInst.CpuStatus & " ] CPU is Idle")
        Case Is = 5: Call .AddItem("CpuStatus :" & vbTab & "[ " & wmiInst.CpuStatus & " ] Reserved")
        Case Is = 6: Call .AddItem("CpuStatus :" & vbTab & "[ " & wmiInst.CpuStatus & " ] Reserved")
        Case Is = 7: Call .AddItem("CpuStatus :" & vbTab & "[ " & wmiInst.CpuStatus & " ] Other")
      End Select
      Call .AddItem("CurrentClockSpeed :" & vbTab & wmiInst.CurrentClockSpeed & " Mhz.")
      Call .AddItem("CurrentVoltage :" & vbTab & wmiInst.CurrentVoltage & " Volt")
      Call .AddItem("ExtClock :" & vbTab & wmiInst.ExtClock & " External clock frequency in MHz")
      Family = wmiInst.Family
      Select Case Family
        Case Is = 1: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Other")
        Case Is = 2: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Unknown")
        Case Is = 3: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 8086")
        Case Is = 4: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 80286")
        Case Is = 5: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 80386")
        Case Is = 6: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 80486")
        Case Is = 7: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 8087")
        Case Is = 8: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 80287")
        Case Is = 9: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 80387")
        Case Is = 10: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 80487")
        Case Is = 11: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Pentium brand")
        Case Is = 12: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Pentium Pro")
        Case Is = 13: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Pentium II")
        Case Is = 14: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Pentium processor with MMX technology")
        Case Is = 15: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Celeron")
        Case Is = 16: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Pentium II Xeon")
        Case Is = 17: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Pentium III")
        Case Is = 18: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] M1 Family")
        Case Is = 19: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] M2 Family")
        Case Is = 24: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] K5 Family")
        Case Is = 25: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] K6 Family")
        Case Is = 26: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] K6-2")
        Case Is = 27: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] K6-3")
        Case Is = 28: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] AMD Athlon Processor Family")
        Case Is = 29: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] AMD Duron Processor")
        Case Is = 30: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] AMD2900 Family")
        Case Is = 31: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] K6-2+")
        Case Is = 32: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Power PC Family")
        Case Is = 33: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Power PC 601")
        Case Is = 34: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Power PC 603")
        Case Is = 35: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Power PC 603+")
        Case Is = 36: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Power PC 604")
        Case Is = 37: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Power PC 620")
        Case Is = 38: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Power PC X704")
        Case Is = 39: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Power PC 750")
        Case Is = 48: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Alpha Family")
        Case Is = 49: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Alpha 21064")
        Case Is = 50: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Alpha 21066")
        Case Is = 51: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Alpha 21164")
        Case Is = 52: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Alpha 21164PC")
        Case Is = 53: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Alpha 21164a")
        Case Is = 54: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Alpha 21264")
        Case Is = 55: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Alpha 21364")
        Case Is = 64: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] MIPS Family")
        Case Is = 65: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] MIPS R4000")
        Case Is = 66: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] MIPS R4200")
        Case Is = 67: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] MIPS R4400")
        Case Is = 68: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] MIPS R4600")
        Case Is = 69: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] MIPS R10000")
        Case Is = 80: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] SPARC Family")
        Case Is = 81: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] SuperSPARC")
        Case Is = 82: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] microSPARC II")
        Case Is = 83: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] microSPARC IIep")
        Case Is = 84: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] UltraSPARC")
        Case Is = 85: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] UltraSPARC II")
        Case Is = 86: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] UltraSPARC IIi")
        Case Is = 87: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] UltraSPARC III")
        Case Is = 88: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] UltraSPARC IIIi")
        Case Is = 96: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 68040")
        Case Is = 97: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 68xxx Family")
        Case Is = 98: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 68000")
        Case Is = 99: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 68010")
        Case Is = 100: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 68020")
        Case Is = 101: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 68030")
        Case Is = 112: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Hobbit Family")
        Case Is = 120: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Crusoe TM5000 Family")
        Case Is = 121: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Crusoe TM3000 Family")
        Case Is = 128: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Weitek")
        Case Is = 130: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Itanium Processor")
        Case Is = 144: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] PA-RISC Family")
        Case Is = 145: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] PA-RISC 8500")
        Case Is = 146: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] PA-RISC 8000")
        Case Is = 147: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] PA-RISC 7300LC")
        Case Is = 148: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] PA-RISC 7200")
        Case Is = 149: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] PA-RISC 7100LC")
        Case Is = 150: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] PA-RISC 7100")
        Case Is = 160: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] V30 Family")
        Case Is = 176: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Pentium III Xeon")
        Case Is = 177: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Pentium III Processor with Intel SpeedStep Technology")
        Case Is = 178: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Pentium 4")
        Case Is = 179: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Intel Xeon")
        Case Is = 180: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] AS400 Family")
        Case Is = 181: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Intel Xeon processor MP")
        Case Is = 182: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] AMD AthlonXP Family")
        Case Is = 183: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] AMD AthlonMP Family")
        Case Is = 184: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Intel Itanium 2")
        Case Is = 185: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] AMD Opteron Family")
        Case Is = 190: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] K7")
        Case Is = 200: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] IBM390 Family")
        Case Is = 201: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] G4")
        Case Is = 202: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] G5")
        Case Is = 250: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] i860")
        Case Is = 251: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] i960")
        Case Is = 260: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] SH-3")
        Case Is = 261: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] SH-4")
        Case Is = 280: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] ARM")
        Case Is = 281: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] StrongARM")
        Case Is = 300: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] 6x86")
        Case Is = 301: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] MediaGX")
        Case Is = 302: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] MII")
        Case Is = 320: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] WinChip")
        Case Is = 350: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] DSP")
        Case Is = 500: Call .AddItem("Family :" & vbTab & "[ " & wmiInst.Family & " ] Video Processor")
      End Select
      Call .AddItem("L2CacheSize :" & vbTab & wmiInst.L2CacheSize & " Kb")
      Call .AddItem("MaxClockSpeed :" & vbTab & wmiInst.MaxClockSpeed & " Mhz.")
      Call .AddItem("Manufacturer :" & vbTab & wmiInst.Manufacturer)
      Call .AddItem("PowerManagementSup. :" & vbTab & wmiInst.PowerManagementSupported)
      Call .AddItem("ProcessorId :" & vbTab & wmiInst.ProcessorId)
      ProcessorType = wmiInst.ProcessorType
      Select Case ProcessorType
        Case Is = 1: Call .AddItem("ProcessorType :" & vbTab & "[ " & wmiInst.ProcessorType & " ] Other")
        Case Is = 2: Call .AddItem("ProcessorType :" & vbTab & "[ " & wmiInst.ProcessorType & " ] Unknown")
        Case Is = 3: Call .AddItem("ProcessorType :" & vbTab & "[ " & wmiInst.ProcessorType & " ] Central Processor")
        Case Is = 4: Call .AddItem("ProcessorType :" & vbTab & "[ " & wmiInst.ProcessorType & " ] Math Processor")
        Case Is = 5: Call .AddItem("ProcessorType :" & vbTab & "[ " & wmiInst.ProcessorType & " ] DSP Processor")
        Case Is = 6: Call .AddItem("ProcessorType :" & vbTab & "[ " & wmiInst.ProcessorType & " ] Video Processor")
      End Select
      Call .AddItem("Revision :" & vbTab & wmiInst.Revision)
      Call .AddItem("Role :" & vbTab & wmiInst.Role)
      Call .AddItem("SocketDesignation :" & vbTab & wmiInst.SocketDesignation)
      Call .AddItem("Status :" & vbTab & wmiInst.Status)
      StatusInfo = wmiInst.StatusInfo
      Select Case StatusInfo
        Case Is = 1: Call .AddItem("StatusInfo :" & vbTab & "[ " & wmiInst.StatusInfo & " ] Other")
        Case Is = 2: Call .AddItem("StatusInfo :" & vbTab & "[ " & wmiInst.StatusInfo & " ] Unknown")
        Case Is = 3: Call .AddItem("StatusInfo :" & vbTab & "[ " & wmiInst.StatusInfo & " ] Enabled")
        Case Is = 4: Call .AddItem("StatusInfo :" & vbTab & "[ " & wmiInst.StatusInfo & " ] Disabled")
        Case Is = 5: Call .AddItem("StatusInfo :" & vbTab & "[ " & wmiInst.StatusInfo & " ] Not Applicable")
      End Select
      UpgradeMethod = wmiInst.UpgradeMethod
      Select Case UpgradeMethod
        Case Is = 1: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] Other")
        Case Is = 2: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] Unknown")
        Case Is = 3: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] Daughter Board")
        Case Is = 4: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] ZIF Socket")
        Case Is = 5: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] Replacement/Piggy Back")
        Case Is = 6: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] None")
        Case Is = 7: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] LIF Socket")
        Case Is = 8: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] Slot 1")
        Case Is = 9: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] Slot 2")
        Case Is = 10: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] 370 Pin Socket")
        Case Is = 11: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] Slot A")
        Case Is = 12: Call .AddItem("UpgradeMethod :" & vbTab & "[ " & wmiInst.UpgradeMethod & " ] Slot M")
      End Select
      Call .AddItem("Version :" & vbTab & wmiInst.Version)
    End With
  Next
  Command2.Enabled = List1.ListCount > 0
  Command3.Enabled = List1.ListCount > 0
End Sub

Private Sub Command1_Click()
  Select Case Index
    Case Is = 0:
      If blInstalled Then
        Call GetProcessorInformation(List1)
      Else
        Exit Sub
      End If
    Case Is = 1: Call Unload(Me)
  End Select
End Sub

Private Sub Form_Load()
  On Error Resume Next
  Command1.Caption = "Get Processor Info"

  Set wmiService = GetObject("winmgmts:")
  If Err.Number <> 0 Then
    blInstalled = 0
    Call MsgBox("Windows Management Instrumentation (WMI) is not installed on your system.", vbInformation, "Info...")
  Else
    blInstalled = -1
  End If
  On Error GoTo 0
  '
  Const Columns = 2
  Const TabWidth = 100
  Call SetColumnsToListbox(List1, Columns, TabWidth)
End Sub

Private Sub SetColumnsToListbox(ByRef lb As ListBox, ByVal ColumnCount As Integer, _
                           ByVal ColumnWidth As Integer)
  Dim n      As Integer
  Dim arrCols()  As Long

  On Error GoTo procErr

  ReDim arrCols(ColumnCount - 1)
  For n = 0 To ColumnCount - 1
    arrCols(n) = n * ColumnWidth
  Next
  Call SendMessage(lb.hwnd, LB_SETTABSTOPS, ColumnCount, arrCols(0))
ExitSub:
  Exit Sub
procErr:
  Call MsgBox("Error...", vbCritical, "Error...")
  Resume ExitSub
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.