Solved

Machine Identification

Posted on 2001-07-23
9
179 Views
Last Modified: 2012-05-07
Hi experts,

I need to uniquely identify a computer system. I need this for generating a unique value based on the hardware, it could be the network card number or probably the CPU speed.

Literally anything that does not change when the system is formatted. I am currently using ActiveLock but every time you format the system the ActiveLock key changes. I hope that my requirement is clear.

Thankx for any help in advance
0
Comment
Question by:Murtuza111000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 6308342
Use the MAC address of the machine itself:

http://www.btinternet.com/~vbadmincode/code/getmacadr.zip
0
 

Author Comment

by:Murtuza111000
ID: 6308356
That was really very quick TimCottee, I will checkout the link
0
 

Author Comment

by:Murtuza111000
ID: 6308367
Went thru the project, but would this work on a system where there is no network card installed.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 8

Expert Comment

by:DennisBorg
ID: 6308858
:ping:
0
 
LVL 28

Expert Comment

by:Ark
ID: 6310821
Hi
'For w95/98 via direct memory access.NT/2000 doesn't map
'these addresses into process space, so this code cause GPF.
'See section below how to get these info for NT/2000.

Option Explicit
Private Type BiosData
  Date As Date
  Manufacturer As String
  Version As String
End Type

'Change following declaration to fit your vb version

Private Declare Sub GetMem1 Lib "msvbvm50.dll" (ByVal MemAddress As Long, var As Byte)

Private Function GetBIOSData() As BiosData
 Dim p As Byte, MemAddr As Long, sBios As String
 Dim i As Integer
 sBios = "" 
 MemAddr = &HFE061
 For i = 0 To 25
     Call GetMem1(MemAddr + i, p)
     If p = 0 Then p = 32
     sBios = sBios & Chr$(p)
 Next i
 GetBIOSData.Version = sBios
 MemAddr = &HFFFF5
 sBios = "" 
 For i = 0 To 7
     Call GetMem1(MemAddr + i, p)
     If p = 0 Then p = 32
     sBios = sBios & Chr$(p)
 Next i
 GetBIOSData.Date = CDate(sBios)
 MemAddr = &HFE030
 sBios = "" 
 For i = 0 To 18
     Call GetMem1(MemAddr + i, p)
     If p = 0 Then p = 32
     sBios = sBios & Chr$(p)
 Next i
 GetBIOSData.Manufacturer = sBios
End Function

Private Sub Form_Load()
 Dim bd As BiosData
 bd = GetBIOSData
 Text1 = "BIOS date = " & bd.Date & vbCrLf & "Manufacturer = " & bd.Manufacturer & vbCrLf & "BIOS ver.
= " & bd.Version
End Sub

' For all platforms via registry reading. Can not check on NT, but you can just search your registry using regedit
and change data location in code:

---Bas module code---
Private Const REG_SZ As Long = 1
Private Const REG_DWORD As Long = 4
Private Const HKEY_LOCAL_MACHINE As Long = &H80000002

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal
lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As
Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData
As Long) As Long

Private Function regQuery_A_Key(ByVal hKey As Long, ByVal sRegKeyPath As String, ByVal sRegSubKey As
String) As Variant
 Dim iPos As Integer
 Dim lKeyHandle As Long
 Dim lRet As Long
 Dim lDataType As Long
 Dim lBufferSize As Long
 Dim lBuffer As Long
 Dim sBuffer As String
 Dim arBuffer() As Byte
 lKeyHandle = 0
 lBufferSize = 0
 regQuery_A_Key = "" 
 lRet = RegOpenKey(hKey, sRegKeyPath, lKeyHandle)
 If lKeyHandle = 0 Then GoTo FuncFail
 lRet = RegQueryValueEx(lKeyHandle, sRegSubKey, 0&, lDataType, ByVal 0&, lBufferSize)
 If lKeyHandle = 0 Then GoTo FuncFail
 Select Case lDataType
        Case REG_SZ:       ' String
             sBuffer = Space(lBufferSize)
             lRet = RegQueryValueEx(lKeyHandle, sRegSubKey, 0&, 0&, ByVal sBuffer, lBufferSize)
             If lRet = ERROR_SUCCESS Then
                iPos = InStr(1, sBuffer, Chr(0))
                If iPos > 0 Then
                    regQuery_A_Key = Left(sBuffer, iPos - 1)
                Else
                    regQuery_A_Key = sBuffer
                End If
             End If
        Case REG_DWORD:
             lRet = RegQueryValueEx(lKeyHandle, sRegSubKey, 0&, lDataType, lBuffer, 4&)            
                           ' 4& = 4-byte word (long integer)
             If lRet = ERROR_SUCCESS Then
                regQuery_A_Key = lBuffer
             End If
        Case Else:
 End Select
FuncFail:
lRet = RegCloseKey(lKeyHandle)
End Function

Public Function GetBiosVer() As String
  GetBiosVer = regQuery_A_Key(HKEY_LOCAL_MACHINE, "Enum\Root\*PNP0C01\0000", "BiosVersion")
End Function

Public Function GetBiosDate() As String
  GetBiosDate = regQuery_A_Key(HKEY_LOCAL_MACHINE, "Enum\Root\*PNP0C01\0000", "BiosDate")
End Function

Public Function GetBiosMfr() As String
GetBiosMfr = regQuery_A_Key(HKEY_LOCAL_MACHINE, "Enum\Root\*PNP0C01\0000", "BiosName")
End Function

'--- Form code---
' Add one command button at form
Private Sub Command1_Click()
Me.Print "BiosDate = "; GetBiosDate
Me.Print "BiosVersion = "; GetBiosVer
Me.Print "BiosName = "; GetBiosMfr
End Sub

Cheers
0
 

Author Comment

by:Murtuza111000
ID: 6321385
Ark,

Thank you for this peice of code,I checked it on a Win98 system and it runs fine, but the alternate method on a WinNT4.0 and Windows2000 does not seen to work. There is no registry key PNP0C01\0000 on any of the winnt systems

I find HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\Root\*PNP0C01\PnPBIOS_8 key on a WinNT2000 system but again this no values like "BiosDate",BiosName" and "BiosVersion"

And again even if I do locate these entries in the registry, they are editable values by the user, now that is a different question how many users may actually play around these values, and also that system might be refreshing the values at boot.

TimCottee's solution might work only on systems that have a network card. something similar that might work on systems without network card would be perfect.
0
 

Author Comment

by:Murtuza111000
ID: 6321395
Correction:

TimCottee's solution might work only on systems that have a network card. something similar that might
work on systems without network card would be perfect.

TimCottee's solution does not work on systems that do not have a network card.
0
 

Author Comment

by:Murtuza111000
ID: 6354870
Thank you Ark for the suggestion, but as I mentioned that this approach has its pitfall, although TimCottee's partially answers my question but that is something what I am looking for.

I think I will settle for TimCottee's suggestion.

Thank you for the help.
0
 

Author Comment

by:Murtuza111000
ID: 6354873
Do let me know If my question can be fully answered

Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question