Solved

Unique machine ID

Posted on 2000-05-01
14
260 Views
Last Modified: 2012-06-21
How can I get an ID that is the same for one machine across reboots, but it is different for each machine?

It must exist on both Windows 9x and NT/2000.
0
Comment
Question by:luisr
14 Comments
 
LVL 9

Expert Comment

by:Ruchi
ID: 2767908
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=6249

"The code shows you User ID, Hostname, IP adress, and Port number of the local machine."
0
 
LVL 3

Author Comment

by:luisr
ID: 2768004
Sometimes the computer will not have access to the internet or even a network adapter installed. I don't think the IP address would do it.
0
 
LVL 2

Expert Comment

by:JetScootr
ID: 2768019
The hostname is a character string, easily obtained by Ruchi's suggested method (or several others).  But users can change the CPU name.
A couple of years ago, Intel got in very hot Public Relations waters for wanting to put serial numbers in the CPUs for this very purpose.  The privacy implications are unacceptable to most people, so the computer hardware is (mostly) anonymous and what you're asking for doesn't exist.  The Internet industry has somewhat gotten around this by the use of cookies.  Cookies, in essence, are unique files that you would store on each machine, and you would put unique data in the file, or in the filename, so you could retrieve it later.  Within a corporate setting, this is probably just as acceptable as uniquely ID'ing the hardware.
0
 
LVL 3

Author Comment

by:luisr
ID: 2768037
It does not have a hardware ID... some kind of data that is generated at Windows setup and will remain the same after each boot. The idea is for a program to know it is being run on the machine on which it was installed, and not copied to another one.
0
 
LVL 3

Author Comment

by:luisr
ID: 2768039
Oops... In my previous comment "It does not have a hardware ID" should have been "It does not have to be a hardware ID"
0
 

Expert Comment

by:korky
ID: 2768609
Take the value of the Timer method and save it in the registry
0
 
LVL 4

Accepted Solution

by:
arcusd earned 100 total points
ID: 2768692
you can try using the volume id of the hard disk..if u want to use
u can try this code

'drive info
Public Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (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
Public Const GETDI_SERIAL = 1
Public Const GETDI_LABEL = 2
Public Const GETDI_TYPE = 3

Function GetDriveInfo(strDrive As String, iType As Integer)
   Dim SerialNum As Long
   Dim strLabel As String
   Dim strType As String
   Dim lRetVal As Long
   
   strLabel = Space(256)
   strType = Space(256)
   lRetVal = GetVolumeInformation(strDrive, strLabel, Len(strLabel), SerialNum, 0, 0, strType, Len(strType))
   Select Case iType
      Case Is = 1
         GetDriveInfo = CStr(SerialNum)
      Case Is = 2
         GetDriveInfo = strLabel
      Case Is = 3
         GetDriveInfo = strType
   End Select

End Function


so to get the volumeID of the hd

volid = getDriveInf("c",1)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Author Comment

by:luisr
ID: 2769747
arcusd, I guess that should work, I'll give it a try.
0
 
LVL 3

Author Comment

by:luisr
ID: 2770646
I think that will work... but does it work for UNC paths? how?
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2770766
Information about UNC paths:
http://www.avdf.com/june98/art_vb006.html
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2770778
I think this is what you are looking for.

http://www.vb2themax.com/Item.asp?PageID=CodeBank&ID=89
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2770794
Convert from a file path to a UNC path.

http://www.vb2themax.com/Item.asp?PageID=CodeBank&ID=64
0
 
LVL 3

Author Comment

by:luisr
ID: 2770898
My question is if arcusd's routine will work for UNC paths?? If I run my program through the network, how do I know it is valid if I compare the stored volume ID to that of the machine it is running on?
0
 
LVL 3

Author Comment

by:luisr
ID: 2790165
Thanks for the tip, you got me on the right track. I still had to modify it a little bit to work for my situation.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 56
Validating VB6 Function 19 56
VBA error replacing data 6 37
Hide vba in gp 7 80
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

919 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

17 Experts available now in Live!

Get 1:1 Help Now