Attached is my ULicenseManager unit for validation and activation of license codes generated by demo OnGUard code generation program in the CodeOcean.
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!

You can use it 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;