unit test_unit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TfrmRegistration = class(TForm)
    btnRegister: TButton;
    btnExit: TButton;
    eUserInfo: TEdit;
    eKey: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    Label2: TLabel;
    Label5: TLabel;
    lbUserInfo: TLabel;
    lbKey: TLabel;
    Bevel1: TBevel;
    btnDeleteKey: TButton;
    Label1: TLabel;
    procedure btnExitClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure btnRegisterClick(Sender: TObject);
    procedure btnDeleteKeyClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmRegistration: TfrmRegistration;

implementation

uses enigma_ide;

{$R *.dfm}

procedure TfrmRegistration.btnExitClick(Sender: TObject);
begin
  Application.Terminate;
end;

procedure TfrmRegistration.FormShow(Sender: TObject);
var
  pcKey, pcUserInfo : PChar;
begin
  {$I Inc/reg_crypt_begin.inc}
  Label1.Visible := false;
  if LoadKey(pcUserInfo, pcKey) then
  begin
    lbUserInfo.Caption := pcUserInfo;
    lbKey.Caption := pcKey;
  end;
  {$I Inc/reg_crypt_end.inc}
end;

procedure TfrmRegistration.btnRegisterClick(Sender: TObject);
begin
  if SaveKey(PChar(eUserInfo.Text), PChar(eKey.Text)) then
    ShowMessage('Thanks for registration! Restart application to complete registration.');
end;

procedure TfrmRegistration.btnDeleteKeyClick(Sender: TObject);
begin
  DeleteKey;
end;

end.
