How to get CPU Serial No. or other unique machine ID's

I want to 'brand' the data created in my VB6.0 app so that I can recognize data that has been created on another machine.  I am crrently using

Public Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

to get the username and using that to 'brand' the data.  This is working but it is possible that two machines or users coudl return the same value.

Is it possible from within VB6.0 to retrieve the CPU serial number or some other value that would be unique to a machine?  It owuld have ot be some value that would be on one and only one machine.  I could use this for my branding
LVL 1
mlcktmguyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nffvrxqgrcfqvvcCommented:
Maybe BIOS serial number... Otherwise I would shoot for computers GUID


Option Explicit

Private Declare Function GetComputerNameW Lib "kernel32" ( _
    ByVal buf As Long, _
    nSize As Long) As Long

Public Function BIOSSerial() As String
 
    Dim B(255)       As Byte
    Dim PC           As String
    Dim obsrv        As Object
    Dim obItm        As Object
    Dim varItm       As Variant

    GetComputerNameW ByVal VarPtr(B(0)), 255
    PC = Left$(B, InStr(B, Chr(0)) - 1)
   
    Set obsrv = GetObject("winmgmts:\\" & PC)
    Set obItm = obsrv.ExecQuery("Select * from Win32_BIOS", , 48)
    For Each varItm In obItm
        BIOSSerial = varItm.SerialNumber
    Next
   
    Set obsrv = Nothing
    Set obItm = Nothing
   
End Function


Private Sub Command1_Click()
MsgBox BIOSSerial
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.