Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Computer ID 2

Status
Not open for further replies.

WoodyRoundUp

Programmer
Feb 28, 2001
187
AU
HI all vb Maniac,
just want to get to know how do we get a Computer ID? i think every pc has their own unique ID rite? how do i find that out? thanks guys.

ME
 
Try this:[tt]

Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type

Private Declare Function CoCreateGuid Lib "OLE32.DLL" (pGuid As GUID) As Long

Private Function GetGUID() As String
Dim udtGUID As GUID
If (CoCreateGuid(udtGUID) = 0) Then
GetGUID = _
String(8 - Len(Hex$(udtGUID.Data1)), "0") & _
Hex$(udtGUID.Data1) & _
String(4 - Len(Hex$(udtGUID.Data2)), "0") & _
Hex$(udtGUID.Data2) & _
String(4 - Len(Hex$(udtGUID.Data3)), "0") & _
Hex$(udtGUID.Data3) & _
IIf((udtGUID.Data4(0) < &H10), &quot;0&quot;, &quot;&quot;) & _
Hex$(udtGUID.Data4(0)) & _
IIf((udtGUID.Data4(1) < &H10), &quot;0&quot;, &quot;&quot;) & _
Hex$(udtGUID.Data4(1)) & _
IIf((udtGUID.Data4(2) < &H10), &quot;0&quot;, &quot;&quot;) & _
Hex$(udtGUID.Data4(2)) & _
IIf((udtGUID.Data4(3) < &H10), &quot;0&quot;, &quot;&quot;) & _
Hex$(udtGUID.Data4(3)) & _
IIf((udtGUID.Data4(4) < &H10), &quot;0&quot;, &quot;&quot;) & _
Hex$(udtGUID.Data4(4)) & _
IIf((udtGUID.Data4(5) < &H10), &quot;0&quot;, &quot;&quot;) & _
Hex$(udtGUID.Data4(5)) & _
IIf((udtGUID.Data4(6) < &H10), &quot;0&quot;, &quot;&quot;) & _
Hex$(udtGUID.Data4(6)) & _
IIf((udtGUID.Data4(7) < &H10), &quot;0&quot;, &quot;&quot;) & _
Hex$(udtGUID.Data4(7))
End If
End Function

Private Sub Form_Load()
MsgBox GetGUID
End Sub
[/tt]

Microsoft claims you will never find two systems with the same GUID (like snow flakes).
VCA.gif
 
Problem with technique is that every time it is run you get a different GUID...

 
Problem with this technique is that every time it is run you get a different GUID (on the other hand it is great for determining the MAC address of your PC)

 
hi guys. Thanks for the reply. but, it seems that everytime it's executed, the id is different. is there any way to solve it?
thanks.
 
Public Declare Function GetComputerName Lib &quot;kernel32&quot; Alias &quot;GetComputerNameA&quot; (ByVal lpBuffer As String, nSize As Long) As Long

???
 
:~/Oops... sorry about posting without thinking:~/.

The following might actually work. It uses the least-often changed component of a system (the ROM-BIOS) to create an identifier.

This might require additional thought (I haven't compared the values retrieved from two systems with identical BIOS versions. Hopefully, somebody can help out here.)

Note, also, that this scheme uses the CopyMemory. The results under WinNT and 2000 might be a bit... er... too consistent
[tt]
Private Declare Sub CopyMemory _
Lib &quot;kernel32&quot; Alias &quot;RtlMoveMemory&quot; _
(dest As Any, _
source As Any, _
ByVal bytes As Long)

Sub Main()
G$ = Space$(&H10000)
[/tt]
' Get 65536 bytes of reserved ROM-BIOS memory.[tt]
CopyMemory ByVal G$, ByVal &HF0000, &H10000
Z$ = String$(8, &quot;0&quot;)
[/tt]
' Create an 80 byte hexadecimal checksum
' and throw in some dashes to make it readable.
' (The checksum creation is somewhat flawed...
' Perhaps somebody will suggest a better way.).[tt]
For Re = 1 To 10
For byt& = 1 To &H1000
Chk& = Chk& + Asc(Mid$(G$, byt& - 1 + (Re * &H1000), 1)) * byt&
Next
Chksum$ = Chksum$ & Right$(Z$ + Hex$(Chk&), 8) & &quot;-&quot;
Chk& = 0
Next
Chksum$ = Left$(Chksum$, Len(Chksum$) - 1)
G$ = &quot;&quot;
MsgBox &quot;System ID(???): &quot; & Chksum$
End Sub
[/tt]

Any thoughts?

VCA.gif
 
aahh, the old question about unique computer ID's :)
unfortunatelly the bios sub didn't work for me (XP user),
but i found something else .. ok, it's Russian, but it's a very very nice way to get an unique hardware identification.
Just use the S.M.A.R.T interface to get your hardisk's serial number, controller revision, and model number.
Now you know for each model number each harddisk gets an unique serial number,
combine these three together and you may be very sure you have an unique ID for each pc in the world. Even when the harddrive is formatted, the ID will stay the same, neet huh ;-)

although one remark: you need at least one harddrive to be connected to IDE0 or IDE1 at the motherboard,
so when someone has all his harddrives connected to SCSI controllers, it won't work,
a getaround for this would be to ask the user to switch his IDE cable for a second to IDE0 but he might not be very happy with that :) because it's not very pratical and windows might not find his harddisk and won't start that way.

also if anyone can help me to add serious protection against cracking to this project i would be very gratefull.

thanx in advance


greetings,
teddy4you21
 
ok .. it seems the location for the file has been changed,
so here's the new one:

and some information i forgot to mention:

SMARTInfo.ocx - requires mfc42.dll
smartvsd.vxd - you need it only for Windows 9x/ME,
put it in the c:\windows\system\iosubsys folder if
it is not there yet, and restart windows
One tip: use AutodetectOS flag with true value.

greetings,
teddy4you21
 
Hy! where can i find now the zip file? because i need the serial number of my harddisk!
thanks!
 
Hi, I can't find it either on the website.
I still have a copy of it.
mail: teddy4you21@hotmail.com
 
To return the Volume Serial Number:
Code:
Option Explicit
Declare Function GetVolumeInformation Lib &quot;kernel32&quot; Alias &quot;GetVolumeInformationA&quot; (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long


Sub Main()
    Dim lpRootPathName As String, lpVolumeNameBuffer As String
    Dim nVolumeNameSize As Long, lpVolumeSerialNumber As Long
    Dim lpMaximumComponentLength As Long, lpFileSystemFlags As Long
    Dim lpFileSystemNameBuffer As String, nFileSystemNameSize As Long
    Dim ReturnVal As Long
    lpRootPathName = &quot;C:\&quot;
    ReturnVal = GetVolumeInformation(lpRootPathName, _
                                    lpVolumeNameBuffer, _
                                    nVolumeNameSize, _
                                    lpVolumeSerialNumber, _
                                    lpMaximumComponentLength, _
                                    lpFileSystemFlags, _
                                    lpFileSystemNameBuffer, _
                                    nFileSystemNameSize)
    MsgBox &quot;(&quot; & lpVolumeSerialNumber & &quot;)&quot;
    End
End Sub
 
or the somewhat shorter (requires reference to Microsoft Scripting Runtime):
[tt]
Public Function vbGetSerialNumber(strDrive As String) As String
Dim fso As FileSystemObject
Set fso = New FileSystemObject
vbGetSerialNumber = fso.GetDrive(strDrive).SerialNumber
End Function
 
please note that you can not use the Volume Serial Number (VSN) as a hardware identification number.

Because, when you format your harddrive (or partition) the VSN will change.
And more important the VSN is stored as plain text, in other words, a cracker can easily change the VSN with a tool.

Conlusion: Use the Hardware Serial Number of the harddrive, which is unique in the world, does not change when you format the drive and can not be changed by crackers
(note that the SMARTInfo code still needs some anti-cracking code, this must be done in the C++ code, which will be compiled into an Visual Basic OCX).

greetings,
teddy4you21
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top