tags:

views:

281

answers:

1

Dear all,

can any one help me out in extracting system processor id in vb6.0,, i used following code to extract but only for laptop this code is able to extract processor id but for the desktop it is unable to extract.... The code is as follows......................


Public Function MBSerialNumber() As String

'RETRIEVES SERIAL NUMBER OF MOTHERBOARD
'IF THERE IS MORE THAN ONE MOTHERBOARD, THE SERIAL
'NUMBERS WILL BE DELIMITED BY COMMAS

'YOU MUST HAVE WMI INSTALLED AND A REFERENCE TO
'Microsoft WMI Scripting Library IS REQUIRED

Dim objs As Object

Dim obj As Object
Dim WMI As Object



Set WMI = GetObject("WinMgmts:")
Set objs = WMI.InstancesOf("Win32_BaseBoard")
'Set objs = WMI.InstancesOf(WindowState)
For Each obj In objs
procid = procid & obj.SerialNumber
If procid < objs.Count Then procid = procid & ","
Next
MBSerialNumber = procid
procid = LTrim$(procid)
procid = RTrim$(procid)
MsgBox "Proc_id :" + procid
End Function

P LZ send a solution to my mail id---->[email protected]

+2  A: 

Your code extracts the mother board serial number, not the CPU ID. Use Win32_Processor instead of Win32_BaseBoard.

See this vbscript code:

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")

For Each objItem in colItems
    Wscript.Echo "Caption: " & objitem.Caption
    Wscript.Echo "CPU ID: " & objItem.ProcessorId    
Next

Will produce:

C:\wmi>wmicpu.vbs Microsoft (R) Windows Script Host Version 5.7 Copyright (C) Microsoft Corporation. All rights reserved.

Caption: x86 Family 6 Model 15 Stepping 6
CPU ID: BFEBFBFF000006F6

For more fields, see this MSDN reference

Christian Vik