//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "test_unit.h"

// Enigma API respondence ---------------------------------------------------
#include "include/enigma_api.h"
#pragma link "include/enigma_ide.lib"
// --------------------------------------------------------------------------

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfrmRegistration *frmRegistration;

  char* pcUserInfo = NULL;
  char* pcKey = NULL;

//---------------------------------------------------------------------------
__fastcall TfrmRegistration::TfrmRegistration(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TfrmRegistration::btnExitClick(TObject *Sender)
{
  ExitProcess(0);
}
//---------------------------------------------------------------------------
void __fastcall TfrmRegistration::FormShow(TObject *Sender)
{
  char	buffer[1024];

  #include "include\reg_crypt_begin.inc"
  // Hide "UNREGISTERED" label if application is registered,
  // key is valid and reg_crypt_section was encrypted
  Label6->Visible = FALSE;
  if (LoadKey(&pcUserInfo, &pcKey))
  {
    lbUserInfo->Caption = pcUserInfo;
    lbKey->Caption = pcKey;
  }
  #include "include\reg_crypt_end.inc"

  eHardware->Text = GetHardwareID();
}
//---------------------------------------------------------------------------
void __fastcall TfrmRegistration::btnRegisterClick(TObject *Sender)
{
  char Key[255];
  char UserInfo[255];

  StrPCopy(UserInfo, eUserInfo->Text);
  StrPCopy(Key, eKey->Text);

  if (SaveKey((char*)UserInfo, (char*)Key))
  {
    ShowMessage("Thanks for registration! Restart application to complete registration.");
  }
}
//---------------------------------------------------------------------------
void __fastcall TfrmRegistration::btnDeleteKeyClick(TObject *Sender)
{
  DeleteKey();
}
//---------------------------------------------------------------------------

