Solved

Machine Identification

Posted on 2001-07-23
9
174 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
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
 
LVL 8

Expert Comment

by:DennisBorg
ID: 6308858
:ping:
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 27

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now