Unique System ID


Is there any way to get some kind of Id which is unique to a system to use with delphi. I want to my application to work only in system it is installed.

Who is Participating?
LRHGuyConnect With a Mentor Commented:
Oops! Sorry, it's CreateMachineID ... I had encapsulated it for my own purposes... It should be in OnGuard.pas.

princemaheshAuthor Commented:
I am using delphi 5 and 7......enterprise version....
Check out Turbopowers' OnGuard package at sourceforge:


It has a routine "GetMachineID" which should suit your needs.

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

princemaheshAuthor Commented:
Hi Larry

Thanks for your comment

I checked these components but there is no method called "GetMachineName"

If the target machine has an ethernet card, the best way would be using MAC address. It is also possible to use CPUID info but it can be disabled.
Wim ten BrinkSelf-employed developerCommented:
Using the MAC address would fail if the user changes the network card in his system or adds a second one... Or if he, like me, has a small USB device that acts as a network card through USB... Then the system might or might not have a MAC address...
princemaheshAuthor Commented:
Ya Larry i found this one....thanks.....

Is this also generate key on the system harware information.....if it does then if user make any change to those harwares then the application won't work.....am i right?

if you want to have unique system ID, that is unique and re-generetable to a system, this id will have to contain some kind of hardware-specific data, be it MAC address or CPUID ...

There is of course the risk of changing hardware and invalidation of key, but you cannot have a unique system id without this risk.

Changing a network card may not be an issue, most new motherboards have built-in ethernet adapters and if you have one working, you possibly use one for several years.

Adding a second ethernet card does NOT affect copy protection, you can always enumarate all adapters and use the registered one.

I do not know much about USB based ethernet cards but I highly suspect they will have an MAC address. They have to have one for windows TCP/IP stack to work. You cannot have ARP tables without MAC addresses.
The CreateMachineId routine takes a parameter...you tell it which "pieces" of the computer to look at to create the ID, so it depends on which parameters you select. You can include user name, drive sizes, network ID...take your pick! IF they change the hardware, the machine ID could change.

> I want to my application to work only in system it is installed.

do you want to check if the program is installed on the system
or should it be a kind of copyprotection and registration so that
the program should only run on systems someone has paid for?
I use a simple approach. Create one myself.
Create a text file and rename it to   myID.reg
It should contain the following:


double click on the file and it gets loaded into Windows registry. fast and simple.
you can change the value and double click as many time as you like, the value would be overwritten.
then read the registry value using this command in your app:

 ComputerID:=ReadHKEY_LOCAL_MACHINE(Software\MyAppOrCompanyName\ComputerID', 'ComputerID');

ReadHKEY_LOCAL_MACHINE is defined as below ( also remember to add registry to your uses clause):

function ReadHKEY_LOCAL_MACHINE(KeyName: string; ValueName: string): string;
  Registry: TRegistry;
  Registry := TRegistry.Create(KEY_READ);
    Registry.RootKey := HKEY_LOCAL_MACHINE;
    // False because we do not want to create it if it doesn't exist
    Registry.OpenKey(KeyName, False);
    Result := Registry.ReadString(ValueName);

if you want more security, remove the xxx.reg file once you are done or use the WriteString method to write the ID value instead of using the text file. And also use a less obvious name for your registry key name, value name, and ID value.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.