Example 2

Top  Previous  Next

 

Items

In this example you will learn to

Protection schemes

Flowchart

Brief practice with example 2a

 

 

In this example you will learn to:

1. Use the component in a basic protection scheme (Scheme B).

 

 

Protection schemes

This example uses the scheme B

 

   Scheme B

layout02

 

It is implemented as shown in the following flowchart:

 

 

 

 

Flowchart

 

demo02a01

procedure TForm1.FormCreate(Sender: TObject);

begin

 DoRegister(False);

end;

 

procedure TForm1.DoRegister(force:boolean);

var F : TRegForm;

begin

 F:=TRegForm.Create(nil); //Create the registration Form

 try

   if AVLockS51.IsLocal and (force or (keydata.DaysLeft < 15)) then F.ShowModal;

 finally

   FreeAndNil(F);

 end;

end;

 

procedure TForm1.Button2Click(Sender: TObject);

begin

 special;

end;

 

procedure TForm1.special;

var F:TForm2;

begin

 if (keydata.Status = Registered) then begin

   F:=TForm2.Create(nil);

   try

     F.showmodal;

   finally

     freeandnil(F);

   end;

 end else showmessage('Special Features not allowed. Only available for registered users.');

end;

 

procedure TForm1.FormPaint(Sender: TObject);

begin

  { //commented in order to go ahead still at not registered status

  if (keydata.Status <> Registered) then begin

    showmessage('Not Registered');

    application.Terminate;

  end;

  }

 if (keydata.TooManyInstances) then begin

   showmessage('Too many instances');

   application.Terminate;

 end;

 if not AVLockS51.IsLocal and (AVLockS51.activeinstances.count < 2) then begin

   showmessage('This application must be run first from the server.');

   application.Terminate;

 end;

end;

 

The scheme is similar to Example 1, with the following changes:

 

1) There has been eliminated from the OnPaint event the section which terminates the execution when the the registration status is not registered, also added the procedure "special" which is executed with the button "Button1" [Special Features].

 

2) Also into GetRegStatus() has been changed the sources used to calculate the InstallCode, using here the following scheme:

 

   InstallCodeSources := Machine_Data;

   MachineSources := [System_UUID, HD_SN];

 

 

3) Also, this example is configured to use the Basic OLM, as follow:

 

{$DEFINE BASIC_OLM} //Options are BASIC_OLM, ADVANCED_OLM, NO_OLM

 

What explained about the parameter "force" in the example 1 is also valid in this example.

 

Version (2a): is the development version, with the utilitarian section including buttons to start the trial period and delete the registration data in order to get back the application to its original status.

Version (2b):  is the final release, where the trial period starts automatically and the utilitarian section were removed.

 

 

Brief practice with example 2a

 

From the Delphi IDE open the example 2a (\Examples\2\a)

 

demo02a02

 

If you like you could follow the steps of the previous example: run the application, start the trial period, remove the registration, etc.