Attaching (see attachment ulicensemanager.pas) my ULicenseManager unit, intended for validation and activation of license code being generated by OnGuard demo program for license codes generation (check in CodeOcean).
It works with CodeTyphon 8.50.
You will see some terrible hacks inside, for example for proper interpretation of encoded dates. It should be probably much better to debug the OnGuard itself. But, hey, it works! :-)
It can be used something like this:
procedure TAboutForm.CheckLicense;
var
LM: TLicenseManager;
Details: string;
NewCode: string;
begin
LM := TLicenseManager.Create(Self);
try
if LM.ActivateLicense(EditLicenseCode.Text, EditMachineCode.Text, Details) then
begin
LabelLicenseStatus.Caption := 'License: VALID';
MemoLicenseStatusDetails.Lines.Text := Details;
MainForm.IsLicenseActive := True;
// Critical update: Refresh license code from storage
NewCode := ReadLicenseCode; // Or use LM's method if available
EditLicenseCode.Text := NewCode; // Update UI with new license code
{$IFDEF DebuggingMode}
DebugLog('🔄 UI License Code Updated: ' + NewCode);
{$ENDIF}
end
else
begin
LabelLicenseStatus.Caption := 'License: INVALID';
MemoLicenseStatusDetails.Lines.Text :=
'Activation Failed' + sLineBreak + Details;
MainForm.IsLicenseActive := False;
end;
finally
LM.Free;
end;
end;