Search code examples
delphidelphi-xe2piracy-prevention

How to prevent a program from being copied, using Delphi


I would like to know, let say I develop a program, have access to the clients computer, is there no way to develop the program so that is can only run on that machine, by writing in the computers unique identifier (if there is something like that) into the code and compiling the program. I'm using Delphi XE2


Solution

  • If you want something simple this will give you the hard disk volume ID as a number which should be unique to each machine bar hacking.

    function GetHDSerialNumber: Dword;
    var dw:DWord; mc, fl : dword; c:string;
    begin
      c:=extractfiledrive(application.exename)+'\';
      GetVolumeInformation(Pchar(c),nil,0,@dw,mc,fl,nil,0);
      Result := dw;
    end;
    

    This works up to Delphi 2007, versions above that are unicode, you're on yer own with that problem.