valega.com
AVLock SIMPLE Online Help
Introduction
What is AVLock SIMPLE?
How to buy AVLock SIMPLE?
Acknowledgments
Using AVLock Simple
How to install AVLock SIMPLE?
Registration Keys
Configuration
Users and Instances
Protection Schemes
Examples
Example 1
Example 2
Example 3
Example 4
Example 5
Example 6
Example 7
Example 8
Properties
Methods
The Online License Manager (OLM)
HowTo's
The RegMonitor utility
The KeyGen utility
The CodeCheck utility
The KeyCheck utility
Additional Information
Changelog
License Agreement

Example 3

Top  Previous  Next

EXAMPLE 3

 

Items

In this example you will learn to

Protection schemes

Flowchart

Brief practice with example 3a

Run the application

Start the trial period

The example 3b

 

 

In this example you will learn to:

1. Using the component in a protection scheme with multiple modules (Scheme C).

2. Manage several modules through the "Values" field.

3. View on a table all registration data of the current registered key.

 

 

Protection schemes

This example uses the scheme C

 

        Scheme C

layout04

 

It is implemented as shown in the following flowchart:

 

 

 

Flowchart

 

demo03a01

procedure TForm1.FormCreate(Sender: TObject);

begin

DoRegister(False);

end;

 

procedure TForm1.DoRegister(force:boolean);

var F : TRegForm;

  ok:boolean;

begin

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

try

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

finally

  FreeAndNil(F);

end;

if (keydata.Status = Registered) then begin

  Button1.Enabled := (IsValueOn(keydata.Values,3,0));

  Button2.Enabled := (IsValueOn(keydata.Values,3,1));

  Button3.Enabled := (IsValueOn(keydata.Values,3,2));

end else begin

  Button1.Enabled := False;

  Button2.Enabled := False;

  Button3.Enabled := False;

end;

end;

 

procedure TForm1.FormPaint(Sender: TObject);

begin

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 AVLockS41.IsLocal and (AVLockS41.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 but now control three special modules with the Values field.

 

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

 

Version (3a): 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 (3b):  is the final release, where the trial period starts automatically and the utilitarian section were removed.

 

 

Brief practice with example 3a

 

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

 

demo03a02

 

 

Run the application

Hit the runbutton button or click F9 to start the program.  In moments you will see the registration form:

 

demo03a03

 

Note that the current registration status is "Not registered". This is because it is first executed the program and for "a" versions, the trial period is not started automatically.

 

We have two choices to start the trial period:

a) Offline way. Using the method MakeTrial () with the [Start Trial with MakeTrial ()] button.

b) Online way. Using the basic OLM with the [Start Trial with Basic OLM] button. The example is configured to access the site www.av-soft.com which you can use to do the practices.

 

If the status is not registered then when clicking the [Continue >>] button, the application will terminate, so the main form will be unaccessible.

 

Start the trial period

 

Related items: How to start the trial period

 

Here besides the buttons to start the trial period there are three check boxes to select the modules you want enabled during the trial.

To test it select Special 1 and Special 3 and click on the button [Start with MakeTrial]. You will see a message box informing the result of the operation, "Trial started":

 

demo01a06

 

You can also see that the current registration status has changed showing the message that you see below:

 

demo01a07

 

Now if you click on the [Continue>>] will go to the main application form where you will see the result of the operation performed:

 

demo03a04

 

You can see there are enabled the buttons that correspond with the selected check boxes. Let us now see more details about how this was done, in the registration form now have a button [Show Registration Data], this brings you to the following screen:

 

demo03a05

 

Here you can see detailed information about the registration status but what we now see in detail as regards the field Values. This is composed of 3 nibbles, a nibble is half a byte and is composed of 4 bits for a total of 3x4 = 12 bits for the Values field. On the screen we can see it represented as a hexadecimal value '005' as binary 0000 0000 0101. As we have used the bits 0, 1 and 2 of the nibble number 3 (Value3) to control access to specific modules. Here is a little source code used to calculate the Values field value based on the selected check boxes:

 

function TRegForm.values:string;

var val: word;

begin

val:=0;

if ch1.Checked then val := 1;

if ch2.Checked then val := val + 2;

if ch3.Checked then val := val + 4;

result := inttohex(val,3);

end;

 

On the val variable is calculated the value which is then allocated to the Values field.

 

if  "Special 1" is checked, add 1 to val   1 = 0001 (binary)

if  "Special 2" is checked, add 2 to val   2 = 0010 (binary)

if  "Special 3" is checked, add 4 to val   4 = 0100 (binary)

 

By checking the boxes "Special 1" and "Special 3" we get (1 + 4) = 5

 

At binary view:

 

Special 1 =  0001

Special 2 =  0100

        -------

Sum       =  0101

 

 

 

The example 3b

 

Here, all utilities were removed from the registration form and the start of the trial period takes place from the OnCreate event of the main form using the StartTrial procedure whose source code is shown below:

 

procedure TRegForm.StartTrial;

begin

if (keydata.Status = Unregistered) then begin

  {$IFDEF NO_OLM}

              //(index,users,inst,startdate,days,values)

   AVLock.MakeTrial(0,1,2,date,30,'007');

  {$ENDIF}

  {$IFDEF BASIC_OLM}

              //values, kind, Index, days, inst)

   AVLock.OnlineGetKeyB('007',0,0,30,1);

  {$ENDIF}

  {$IFDEF ADVANCED_OLM}

              //(index,users,inst,days,values)

   AVLock.OnlineStartTrial(0,1,1,30,'007');

{$ENDIF}

 

  GetRegStatus;

end;

end;

 

 

We used '007 'to the Values field. The nibble 3 that use is equal to 7, in binary 0111, thus enabling the three special modules during the trial. If while the practice you started the trial period using the basic OLM with different values for the Values field, it could not be changed unless you delete the registry on the server as shown in Example 1.