EFileTahi-A Posted February 27, 2006 Posted February 27, 2006 (edited) I thought I could easly do this by retrieving the MacAddress of a computer, but, stupid me, if the computer does not have Network card there is no MacAddress. So what I need is to generate a code based on an unique value of a computer. I just need to know which unique value(s) can I get from the system in order to me to generate a key based in the very same value... If the solution for this is to get all hardware ID, how can I do this? Edited February 28, 2006 by EFileTahi-A Quote
Nate Bross Posted February 27, 2006 Posted February 27, 2006 Here's how to get the unique ID of the harddrive; and hopfully all computers will have one of these. I've used this for some demo projects that I wanted to only run on the demo computer at a trade show... Whenever a disk is formatted, the operating system writes a serial number onto it. This number is not guaranteed to be unique, but as it is a 32 bit integer it is unlikely to find a duplicate! The number is often used as part of a copy protection system. This tip shows you how to retrieve the number. Declarations Copy this code into the declarations section of the project. Private Declare Function GetVolumeInformation Lib _ "kernel32.dll" Alias "GetVolumeInformationA" (ByVal _ lpRootPathName As String, ByVal lpVolumeNameBuffer As _ String, ByVal nVolumeNameSize As Integer, _ lpVolumeSerialNumber As Long, lpMaximumComponentLength _ As Long, lpFileSystemFlags As Long, ByVal _ lpFileSystemNameBuffer As String, ByVal _ nFileSystemNameSize As Long) As Long Code Function GetSerialNumber(strDrive As String) As Long Dim SerialNum As Long Dim Res As Long Dim Temp1 As String Dim Temp2 As String Temp1 = String$(255, Chr$(0)) Temp2 = String$(255, Chr$(0)) Res = GetVolumeInformation(strDrive, Temp1, _ Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2)) GetSerialNumber = SerialNum End Function Use An example of using the above function: 'EDIT- Fixed the \\ not showing up by adding a second \\ Call MsgBox GetSerialNumber("C:\\") This will bring up a message box with the serial number of the C drive. View The Original Entry Here Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
EFileTahi-A Posted February 27, 2006 Author Posted February 27, 2006 (edited) Nice! Thanks Nate, however, I wonder if there is any other method... Can we return the serial number of the Motherboard? Edited February 28, 2006 by EFileTahi-A Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.