Simple key number generator script using delphi

Hello all.. this day i was have a problem to make solution my program, the last i'm learning i'm forget for learning of key generator. but for basic i'll show you make generate number by installation code like this example screenshoot :



the activation has make it from installation code (generate from drive C serial: read here) now this code for learning
var
frmIndez: TfrmIndez;

implementation

{$R *.dfm}

//-- fucntion convert --//
function StringToHex(S: String): string;
var I: Integer;
begin
Result:= '';
for I := 1 to length (S) do
Result:= Result+IntToHex(ord(S[i]),2);
end;


procedure TfrmIndex.btnGenerate(Sender: TObject);
var userID : Integer;
part1,part2,part3 : Integer;
begin
lb2.Caption := StringToHex(Copy(edt3.Text,7,9));

If lb2.Caption <> '' then
userID := StrToInt(labelinstalasicode.Caption);

if (userID < 999999999) and (userID > 100) then
begin
part1 := Round(userID/321);
part2 := Round(userID/213);
part3 := Round(userID/114);
edt4.Text := (IntToStr(part1)+'-'+IntToStr(part2)+'-'+IntToStr(part3));
end;


end;

end.