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 5

Top  Previous  Next

EXAMPLE 5

 

Items

In this example you will learn to

Protection schemes

Flowchart

Brief practice with example 5a

Start the trial period

 

 

In this example you will learn to:

1. Using the component in a protection scheme of multiple modules (schemes D, E and F).

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

3. Manage the number of records allowed in a database application through the "Values" field.

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

 

 

Protection schemes

This example uses the schemes D, E and F

 

 

             Scheme D

layout03

      Scheme E

layout06

                  Scheme F

layout07

 

 

It is implemented as shown in the following flowchart:

 

 

 

Flowchart

 

demo05a01

procedure TForm1.FormCreate(Sender: TObject);

begin

DoRegister(False);

end;

 

function TForm1.maxrecords(n:integer):string;

begin

case n of

0: result:='50';

1: result:='200';

2: result:='1000';

3: result:='5000';

4: result:='20000';

5: result:='100000';

else result := 'Unlimited';

end;

end;

 

procedure TForm1.DoRegister(force:boolean);

var F : TRegForm;

begin

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

try

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

finally

  FreeAndNil(F);

end;

if (keydata.Status = Registered) then begin

  maxrec:=maxrecords(Values2Num(keydata.Values,2));

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

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

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

end else begin

  maxrec := '50';

  Button1.Enabled := False;

  Button2.Enabled := False;

  Button3.Enabled := False;

  Form1.wait(10);

end;

LRecNo.Caption := maxrec;

end;

 

 

The scheme is the same as Example 4 but are now implemented schemes E and F. For the scheme E is added the form "Wait", which is a countdown to encourage the user to register. And for the F-schema controls the maximum number of records allowed (assuming that it is a database application).

 

 

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

 

 

 

Brief practice with example 5a

 

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

 

 

Run the application

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

 

 

demo05a03

 

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.

 

Now while the unregistered status, if you click on [Continue>>], the "wait" screen is displayed with the countdown:

 

demo05a05

 

This screen will also be displayed by clicking on the button [Free Features] from the main form.

 

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.

 

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 period and a "combo box" where you select the number of records allowed.

To test it select Special 1, Special 3 and 1000 records. Click on [Start with MakeTrial] and you will see the following 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, (now without the countdown screen):

 

demo05a04

 

You can see there are enabled the buttons that correspond with the selected check boxes, and also "Max Records Allowed" set to 1000.

 

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:

 

demo05a06

 

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 '025' as binary 0000 0010 0101. As we have used the bits 0, 1 and 2 of the nibble number 3 (Value3) to control access to specific modules. The "MAx Records Allowed" value is saved into the nibble 2.

 

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

 

 

Now let's see the source code for calculating the number of records allowed:

 

function TForm1.maxrecords(n:integer):string;

begin

case n of

0: result:='50';

1: result:='200';

2: result:='1000'; //<---

3: result:='5000';

4: result:='20000';

5: result:='100000';

else result := 'Unlimited';

end;

end;

 

. . .

maxrec:=maxrecords(Values2Num(F.keydata.Values,2));

. . .

 

The Values2Num function, extracts the value field corresponding to the selected nibble and converts it to decimal value.