• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 902
  • Last Modified:

How to get the MotherBoard serial number using Visual basic?

How to the get MotherBoard serial number?

or any unique number can indentify a computer?

I had tired MAC Address, but it doesn't work without network card.

Thank You.
0
morye
Asked:
morye
  • 3
  • 2
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
I think you can get it using this free ActiveX: http://farwalk.51.net/
0
 
moryeAuthor Commented:
To EDDYKT,

I had tired the source code already, but it can't get the mother board number.


To emoreau,

Thank for the site, but I need to combine this function into my program. So, I would like to have the source code ....

Thank You~

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Éric MoreauSenior .Net ConsultantCommented:
why don't you add the OCX to your project?
0
 
EDDYKTCommented:
why not

On hte link you should see

Obtaining Baseboard (Motherboard) Information using WMI



click on the link and use the code.

On the bottom you can use serialnumber

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

Add commandbutton and listview on your form


ie
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2003 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.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'/* used for 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 , , "Product"
      .ColumnHeaders.Add , , "Serial number"
      .View = lvwReport
      .Sorted = False
   End With
   
   Command1.Caption = "BaseBoard Info"

End Sub


Private Sub Command1_Click()

   ListView1.ListItems.Clear
   Call wmiBaseBoardInfo
   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 wmiBaseBoardInfo()

   Dim BaseBoardSet
   Dim bb
   Dim itmx As ListItem
   
   Set BaseBoardSet = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
                                 InstancesOf("Win32_BaseBoard")
     
   On Local Error Resume Next
   
   For Each bb In BaseBoardSet
   
      Set itmx = ListView1.ListItems.Add(, , bb.Product)
      itmx.SubItems(1) = bb.serialnumber
   
   Next

End Sub


0
 
EDDYKTCommented:
why not

On hte link you should see

Obtaining Baseboard (Motherboard) Information using WMI



click on the link and use the code.

On the bottom you can use serialnumber

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

Add commandbutton and listview on your form


ie
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2003 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.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'/* used for 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 , , "Product"
      .ColumnHeaders.Add , , "Serial number"
      .View = lvwReport
      .Sorted = False
   End With
   
   Command1.Caption = "BaseBoard Info"

End Sub


Private Sub Command1_Click()

   ListView1.ListItems.Clear
   Call wmiBaseBoardInfo
   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 wmiBaseBoardInfo()

   Dim BaseBoardSet
   Dim bb
   Dim itmx As ListItem
   
   Set BaseBoardSet = GetObject("winmgmts:{impersonationLevel=impersonate}"). _
                                 InstancesOf("Win32_BaseBoard")
     
   On Local Error Resume Next
   
   For Each bb In BaseBoardSet
   
      Set itmx = ListView1.ListItems.Add(, , bb.Product)
      itmx.SubItems(1) = bb.serialnumber
   
   Next

End Sub


0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now