AV-SOFT.COM
AVLock SIMPLE
Introduction
What is AVLock SIMPLE?
How to buy AVLock SIMPLE?
License Agreement
Using AVLock Simple
How to install AVLock SIMPLE?
How does AVLock SIMPLE work?
Properties
Methods
Brief practice with Demo's
The Online License Manager (OLM)
The RegMonitor utility
The KeyGen utility
The RegisterIt utility
The CodeCheck utility

How does AVLock SIMPLE work?

Top  Previous  Next

 

s31logo_simple70

Suppose the following scenario:

 

After a long time of hard work you finally finished your best application. Now you want to market it and you need that your potential customers can evaluate it before to decide to purchase. But also you need achieve it at a secure way and have in mind several alternatives: 

 

1) When the user installs your application this should work in restricted way (only a basic set of features enabled), also the user may be able to ask for a free trial period in order to evaluate your application with all features activated (e.g. by 30 days) or purchase the product in order to activate all features definitely. See Demo 1.

 

2) When the user installs your application this should start automatically a trial period by some days (e.g. 30 days) and finished this period the user can ask for a extension to the trial period (e.g. 15 days) then finished these periods the application stop of work. Also, at any moment the user should to have the option to purchase and activate definitely your application. See Demos 1, 2 and 3.

 

3) Also you want eventually to add some extra modules (special utilities) to be acquired by the actual users through additional payments. But also they should to have the option to evaluate it by a trial period before to purchase. See Demo 2.

 

4) You have your own website and want to use it in order to automate the whole licensing cycle. All transparent for the user without need to deal with serial numbers and registration codes in order to register the application. Although are aware that some clients would not have a Internet connection and should provide a offline registration alternative. See Demo 1.

 

5) Want to give licenses to be shared by a limited number of users anywhere in the world and control the process by internet. Also want to limit the number of instances of your application in each computer. See Demo 1.

 

6) While the trial period you want to detect when an user get back the system date, perhaps with the purpose to stay using your application after expiration, so you will be able to stop the program when that occurs. See Demos 1.

 

7) Want that each license be only for a machine and therefore the user only could run the application into the registered machine and could not be able to manipulate some data in some way in order to activate your application on another machine, e.g. copying all files and registration data.  (All Demos).

 

8) Want for some special cases, e.g. when the user changes his old computer by a new one and want to translate the license to the new computer and deactivate it from the older. See Demo 1.

 

9) Want fully automatize all three basic steps of the licensing cycle namely: a) Start the trial period, b) Extend the trial period and c) Activate the application. Want to do this process online and in automatic way without need to hit any button. Simply you want that when the application starts this read the proper record from the server and does the appropriate action. See Demo 2.

 

10) Want that your application can be installed into a removable disk (pen drive, memory stick , etc) in order to run into any computer. See the Removable Disk property.

 

With AVLock SIMPLE you will be able to manage all these functionalities. Next let us to explain some basic concepts:

 

Firstly let's see the parts that constitute the licensing mechanism of AVLock SIMPLE.

 

THE APPLICATION AND THE COMPONENT

 

To integrate AVLock SIMPLE into your application, go to your Delphi IDE and start a new application or open a existing one, then drop a AVLock SIMPLE icon from the components palette to a Form, normally into the main form of your application. See below the image.

 

delphiide01

 

 

 

 

component01   

 

Here you can see another representation of the Application and the integrated AVLock SIMPLE.

 

In addition to the published properties that you can see above into the object inspector, there are another properties (public) which must be settled at runtime. See more details in the Properties topic.

 

 

THE MODULES

The modules are control units managed by the component. Each module correspond to a registration key with the following format: XXXXXXX-XXXXXXX-XXXXXXX-XXXXXXX with a total length of 31 characters. A registration key has internally all information needed to control the module that represent, the included fields and its sizes are as follow:

 

Fields of a Registration Key:

regkey01

 

Field        length type

------------- ----  -----

Days            4   word

Users           2   byte

Instances       2   byte

Startdate       4   word

Module          2   byte

iCode           4   word 

AppID           4   word

Values          3   hex string

KeyType         1   nibble

Checksum        2   byte

             ----

Total length   28

 

These fields are concatenated into a single string, then strongly encrypted with the Rijndael algorithm then formated with hyphens to make it more readable, e.g. 98RAWTV-9GP5KLK-T7RMRW9-AD305UQ

 

Meaning of each filed into the registration key

 

Days

Authorized days for the trial or temporal period. For permanent keys this field is 65535.

 

Users

Number of users who will share the same registration key through the OLM. A different record will be created by each user.

 

Instances

Number of instances running at once into the computer.

 

StartDate

Date where start the authorized period for trial and temporal keys. For permanent keys this field is 65535.

 

Module

Numero del módulo. Cada Clave tiene un número de identificación del módulo cuyo valor puede estar entre 0 y 254.

 

iCode

Is the checksum of all data fields into the InstallCode property coming from the hardware and other sources. This is included to be compared later with the one coming from the computer where the application is installed in order to verify it.

 

AppID

Number to identify the application.

 

Values

This is a 3 nibbles value (1.5 bytes). This field was added in v3.0 and allow you to control several options into your application using only one module. This capability eliminates the need to use several modules to control your application. In the sample Demo1 using this field are controlled two options, enabling/disabling two buttons; [Restricted Features] and [Special Features] using the nibble 1,  and we use the nibble 2 as a integer value (0..15) to control the level of access to the database. See the decodevalues() function which takes the whole 3 nibbles and convert it to a array of 12 boolean values. See also the ShowRegData procedure where Values is converted to only one integer value (0..4095) of three integer of 1 nibble each (0..15) or 12 boolean values. 

 

KeyType

This field categorize the key with the following possible values:

0=trial,  1=temporal,  2=permanent,  3=unregister,  4=unregisterall

Add 5 for generic keys as follow: 5=generic-trial, 6=generic-temporal, and so on.

 

CheckSum

Checksum of all above fields. Used later to verify the Key.

 

Into the sample Demo1, with the [Show Registration Data] button, you can see the Registration Data for a module as in the following image:

 

demo1_03

Here you see the data fields extracted from the registration key for a given module using the GetModule() method, where you pass as input parameter the module number and as output parameter a record variable of type TModuleData which receive the fields that you see in the image.

 

Besides the previously mentioned fields there are obtained also other related fields, namely:

 

Status: The registration status for the module. This may be:

1) Unregistered: Meaning the lack of registration. There are no registration key registered for this module. (not functional)

2) Moved: The module was marked to be moved to another computer (not functional).

3) Expired: The authorized period finished for a trial or temporal key. (not functional)

4) Registered: The module is registered and functional.

 

EndDate: Date where finishes the authorized period for a trial or temporal key.

 

Primary: True for a primary registration and False for a secondary  registration. The first registration for a given module into the OLM is marked as primary, the next ones, until reach the number of authorized users are marked as secondary.

 

DateBacked: Takes the same value as the property of the same name; True if the system date was turned back. If so, you would take some action, like terminate the program or call the OnlineCheckDate() method which compares the system date with the obtained from internet using the OLM. See in the sample Demo1 the procedure GetModule().

 

TooManyInstances: True when the number of instances running on the computer exceed the number of authorized instances. If so, you would take some action, like terminate the program.

 

Key: The registration key registered for the given module.

 

Primary ICode:  Checksum from the Primary InstallCode. Only usable for secondary registrations.

 

Primary Installcode:  InstallCode from the primary registration. Only usable for secondary registrations. This code and the previously mentioned ICode are saved together with the registration key for the module in order to compare it later with the ICode (checksum) included into the key. See in the image below how is configured the data module into a secondary registration.

 

regkey02

When the module is registered, the key is concatenated with the InstallCode coming from the primary registration and with the Installcode coming from the local computer. Then this string is strong encrypted and saved with the registration data into the local disk.

 

See in the image the comparisons that take place there, both are needed. So, if the Local InstallCode is not included anyone could copy these registration data from one computer to another in order to use illegally the program. The second comparison avoid this risk.

 

 

For a primary registration both installcode must be the same and identical to the local Installcode.

Besides the data shown above, also are saved two fields of 1 character each, which can take the values 'Y' or 'N', denoting boolean values. The first one for the Moved Status and the second for the Primary field.

 

THE LOCAL REGISTRATION DATA

AVLock SIMPLE holds information into the computer where the application is installed, this information is called REGISTRATION DATA and are classified into two sections: APPLICATION DATA and MODULE DATA.

 

RegData01

This information is saved strongly encrypted into a file (the RegFile) saved into a folder based in the RegFilePath property. By example the file 'FG5U2LVM.avr' located into the 'C:\Document and Settings\All Users\Application Data\avlocks3' folder. This is the location where is saved the RegFile for the Demo1 sample.

See below a sample of the content for this file.

 

[FG5U2LVM]

ad=FC740586F92FEDE5C5ADC86F417747AE3ABAC6F080EF58F97DFE1145F5498303CFEB5738E1F54524B45FF89DBD82B23EA3FEE52840D5F3592255ACFBA653C12B

0=9F8C6F3A53E4D73DF1DC826A99208161D0C123AFCBF016CDC6CF6C72538C9126EBCD01845D8712B6A6056DBE6DA050E8B6F408AA2CFE6AA5F1109C5B9F038AD44C1F16F73F60051137A214FBDDE4E618BD60E8FE13F20B95A98687EBA1AFE436

 

a) THE APPLICATION DATA

In this section is saved some component properties in order to be restored later and also specially required into the RegMonitor utility.

 

Below is a sample for the Application Data into the file:

 

ad=FC740586F92FEDE5C5ADC86F417747AE3ABAC6F080EF58F97DFE1145F5498303CFEB5738E1F54524B45FF89DBD82B23EA3FEE52840D5F3592255ACFBA653C12B

 

The entry start with 'ad' (application data).

 

The data saved into this section are as follow:

 

RandomCode: (match with the RandomCode property)

Only applicable when Random_Number is enabled into the InstallCodeSources. This is a random number calculated when the application runs the first time and take part in the InstallCode property calculation.

 

OtherCode: (match with the OtherCode property)

Only applicable when Other_Source is enabled into the InstallCodeSources. This is a number that should be settled at runtime when the application starts and take part in the InstallCode property calculation. See more details in the Properties topic.

 

ICSrc : (match with the ICSources property)

This is a string representation of the InstallCodeSources property and take 5 digits. e.g. '10100'. Each digit correspond to a source into the InstallCodeSources property. '1' = source active, '0' = source inactive. See more details in the Properties topic.

 

UserName : Name of the user (match with the UserName property).

 

Company : Company of the user (match with the Company property).

 

Email : Email from the user (match with the Email property).

 

AppName : Application name (match with the AppName property).

 

AppVersion : Application versión (match with the AppVersion property).

 

b) THE MODULE DATA

Each module is a entity that allow to control a section (module) into your application.

When you register a module using a Registration Key (RegKey), an entry is generated into this section.

Each module are identified by its module number (1..254). For example, the following is a entry for the module 0:

 

0=9F8C6F3A53E4D73DF1DC826A99208161D0C123AFCBF016CDC6CF6C72538C9126EBCD01845D8712B6A6056DBE6DA050E8B6F408AA2CFE6AA5F1109C5B9F038AD44C1F16F73F60051137A214FBDDE4E618BD60E8FE13F20B95A98687EBA1AFE436

 

The data saved for each module is as follow:

 

RegKey : Registration Key. e.g. 4F5D5H9-RK7CEVW-1G49YFJ-NK10FNT

Moved  : 'Y' when the module is marked to be moved to another computer and 'N' for a normal registration.

Primary : 'Y' for a primary registration and 'N' for a Secondary Registration.

Installcode : Correspond to the local Installcode property. e.g. DF8ACE-DC468A-4561A5-FD2D61

InstallCode Primario : For Secondary registrations this value is the Installcode coming from the Primary Registration from where this depends. For Primary registrations take the same value as the local Installcode.

 

THE REMOTE REGISTRATION DATA (OLM)

If you use the Online License Manager (OLM) to register applications and users, also you will have there a MySQL database with information about your registered applications, users and registered modules.

 

olm02

For each registered module we will have at least one record into the OLM for its primary registration and additional secondary records for users associated to the primary registration until complete the number of authorized users. Below is a list of the data fields held for each record:

 

APPID : AppID property.

STARTDATE : Date from where started the authorized period. 

DAYS : Days for the authorized period.

USERS : Number of authorized users.

INSTANCES : Authorized number of instances to run concurrently into the computer. 

KIND : Type of key (0=Trial, 1=Temporal, 2=Permanent)

APPNAME : Application Name (AppName property).

ICSUM  : Shecksum from the Installcode (ICode property).

ICODE  : InstallCode property.

ICODEP : InstallCode from the primary computer. ICODE and ICODEP are identical for primary records.

MODULE : Module number (1..254)

USERNAME : User name (UserName property).

COMPANY : User company (Company property).

EMAIL : User Email (Email property).

EXTEN : Take 'Y' or 'N' values. 'Y' to authorize to extend the trial period.

PAID : Take 'Y' or 'N' values. 'Y' to authorize to register a new key after the payment.

MOVED : The record has been marked to be moved to another computer.

PRIMAR : The current record is for a primary registration.

LASTKEY : Latest Registered Key.

KEYDATE : Date of the LASTKEY.

VALS : Match with the Values field saved into the Registration Key and retrieved later as part of the TModuleData record using the GetModule() method.

 

 

AND NOW, WHAT WE DO WITH THE DATA?

We saw somerely the data managed for the component where these are saved into the computer where the program is installed (LOCAL DATA) and into the OLM (REMOTE DATA). Next we will consider how this data is managed and which methods are involved to accomplish it. These are some of the more relevant ones:

 

THE WRITEAPPDATA() AND WRITEMODULE() METHODS

 

WriteAppData01

The WriteAppData() method takes the registration data from the properties of the AVLock SIMPLE component into the application and then saves it into the  *.avr registration file into the local hard disk. 

 

The WriteModule() method takes as parameter the Registration Key  (RegKey) for a given module and saves it into the *.avr registration file into the local hard disk.

 

For more information see above these sections: 1. THE APPLICATION AND THE COMPONENT and 2. THE REGISTRATION DATA.

 

THE READAPPDATA() AND GETMODULE() METHODS

 

readappdata01

The ReadAppData() method reads the registration data for the application from the *.avr registration file into the local hard disk and then uses it to fill the AVLock SIMPLE properties into the application. 

 

The GetModule() method reads the registration data for a given module from the *.avr registration file into the local hard disk and then uses it to fill a record variable of type TModuleData into the AVLock SIMPLE component.

 

Now let's see these fields with more details. From a practical view point we can consider the AVLock SIMPLE component as a black box inside the application to which you can send questions and obtain responses. For example, you can use the GetModule() method to query about the status of a given module. In the sample  below we ask for the module 0.

 

 

.

 

 

 

simple01

With AVLock SIMPLE it is able to manage until 254 modules, although never you will need all them.  However with only one we can take control of the application starting a trial period the first time that the application runs, then checking the module status using the GetModule() method each time that the application starts, in order to show the adequate message and allow to the user to continue running the application or blocking it if the time of use has expired or the system date have been backed on or the max number of instances allowed has been reached.

 

In the old samples (v2.1) to control the application we are used the module 0 to manage the main application and the rest of modules to activate/deactivate some other features in the application. However, you are free to chose how to use each module. In the majority of these samples is used the module 0 to manage the whole application and often we refer to application as a synonym  of module.

 

However, now in the new v3.0 has been added the Values field. This could be very suitable to simplify the AVLock SIMPLE utilization allowing to control more things with a single registration key. For example with only one key you will be able to control the main application, several modules (features) and manage also some other things. See Demo 1.

 

 

WHAT IS THE "ONLINE LICENSE MANAGER (OLM)"?

 

olm04a

The Online License Manager (OLM) is a interface between the AVLock SIMPLE component and an internet web site. This allow to the AVLock SIMPLE component request from the web server the generation of a registration key, to save it into an online database, and save also another data about the machine and the user into the online database. etc.

 

There are two versions of the Online License Manager (OLM), the basic version and the advanced version. These are sets of php scripts to be installed into your web server in order to manage online licensing functions and are accessible from your application through a set of methods created for this purpose.

 

The basic version is made up by three php scripts; basickeymanager.php, checkdate.php and genkeys3lib.php. To install it please create a folder (e.g. '/olm3') under the /public_html directory then copy into these files, also create the /olm3/temp folder in order to hold the key files created from the applications when the users starts its trial periods. 

Then you will have a scheme like this:

 

/public_html

       /olm3  <---- (basickeymanager.php, checkdate.php, genkeys3lib.php)

             /temp

 

 

The advanced version is made up by 7 php scripts plus a javascript file which installed will look like the following scheme:

 

/public_html

       /olm3  <--- genkeys3lib.php

                   basickeymanager.php

                   checkdate.php

                   avlocks3_inc.php

                   advancedkeymanager.php

                   s3cpanel.php

                   s3createtable.php

                   sorttable.js

 

             /temp

 

This set of files allow you to accomplish the whole licensing cycle for your application namely; 1) to start the trial period 2), to extend the trial period if needed, 3) to purchase your application 4) to activate your application by the user, and 5) to move the license to another computer. The Demo1 sample shows how to implement each one of these steps.

 

There are some properties into the component to hold the OLM path and the names of the most used php scripts, namely:

 

Property

Value

OlmPath

/olm3

OlmAdvScript

advancedkeymanager.php

OlmBasicScript

basickeymanager.php

OlmCheckScript

checkdate.php

 

So, if you change the name of some script, you also will need to change the relating property value.  

 

There are a lot of methods to access to the OLM using each the proper script:

 

Method

Script

OnlineCheckDate()

checkdate.php

OnlineGetKeyB()

basickeymanager.php

OnlineStartTrial()

advancedkeymanager.php

OnlineExtendTrial()

advancedkeymanager.php

OnlineRegisterKey()

advancedkeymanager.php

OnlineRenew()

advancedkeymanager.php

OnLineSynch()

advancedkeymanager.php

OnLineStartSecondary()

advancedkeymanager.php

OnLineMovePrimary1()

advancedkeymanager.php

OnLineMovePrimary2()

advancedkeymanager.php

OnLineRestorePrimary()

advancedkeymanager.php

OnLineMoveSecondary1()

advancedkeymanager.php

OnLineMoveSecondary2()

advancedkeymanager.php

OnLineRestoreSecondary()

advancedkeymanager.php

OnLineRemoveReg()

advancedkeymanager.php

OnlineFullSynch()

advancedkeymanager.php

 

The advanced version includes the control panel (s3cpanel.php), an online utility to access to the online database in the web server in order to see and edit registration data. both versions are installed into http://av-soft.com so you can use them when you try the component.

 

The basic version is included with the standard edition and the advanced version with the professional and developer editions.  After purchase you will be able to modify and adapt them to your own needs and install them into your own web server. For more information please see the Online Licensing Manager topic.

 

 

HOW TO START THE TRIAL PERIOD?

 

Offline methods (two options)

 

(1) With the MakeTrial() method: This method generates and register a key of trial type according with the parameters passed, e.g. in the following call:

 

MakeTrial(0,2,date,30);

 

There we request the generation of a 30 days trial period, for the module 0, for 2 max allowed users, starting at the actual system date. This method only is called the first time that the application runs, when not found yet the registration data saved in the computer so, the GetModule() return (Status = Unregistered).

The problem with the MakeTrial method is that the user can discover where the registration data is saved then  removes it to get so an new free period.

 

2) Do not initiate the trial period and encourage to the user to ask from you a free trial key to initiate the trial period. This mean that your application will remain unregistered some time. I suggest you do not block the application while this unregistered period, instead enable your application with limited functionality, and encourage to the user to ask from you a free trial key to initiate a full featured trial period. This method is more secure that the first one since when the user removes the registration data the application returns to its original status unregistered. 

 

Online methods (two options)

 

For this approach we utilize the Online License Manager (OLM). For the option (1) with the basic OLM and for the option (2) with the advanced OLM. For both options the operation is totally transparent by the user and initiate a trial period automatically and the user will not need to deal with keys of any kind to get it.

 

Start the trial with the basic OLM:

 

For the basic mode is used the OnlineGetKeyB() method. This method is secure since when the user removes the local registration data, the trial status is restored to the previous state from the data saved in the web site. This mean that, if before to delete the local registration data the status was 5 days to expire, after restoring the data the status still will be the same 5 days to expire. Implemented in the Demo1 on the Other TabSheet and "Start Trial" button.

 

starttrial01

 

The call is made with the following line: 

 

OnlineGetKeyB('000',0,0,30,1); 

 

The parameters are:

'000' : Values.

0 : Kind (0=Trial).

0 : Module number.

30 : Trial Days.

1 : Authorized instances.

 

Start the trial with the advanced OLM:

 

See a sample on Demo1, Primary Registration TabSheet and "Start Trial" button. 

 

starttrial02

 

startonlinetrial02

For the advanced mode is used the OnlineStartTrial() method, see at the left image the steps taken to start the trial period:

 

1. (red). A call to the OnlineStartTrial() method like in the next line:

 

OnlineStartTrial(0);

 

The parameter is:

0 : The module number.

 

There are no parameters for Values, Kind, Days and Instances since for these values are used some predefined constants into the genkeys3lib.php script. If  you want to use different values please change the following lines into this file:

 

$trialdays      = 30;

$extendays      = 15;

$trialusers     = 1;

$trialinstances = 1;

$trialvalues    = '000';

 

2. (green). The script advancedkeymanager.php into the server generates a registration key for the given module, then generates a new record into the OLM  to manage this module and return the calculated key to the computer where is saved into the local registration data. If the call is made when the trial period is already started, instead to create a new record there is read and returned the key from the existing record. 

 

HOW TO EXTEND THE TRIAL PERIOD?

 

Offline way:

 

Send to the user a key of trial type to register your application. Generate the key using the KeyGen utility and set there the number of days that you want to extend the trial period.

 

Online Method:

 

See a sample in Demo1. Into the Registration Form into the TabSheet PrimaryRegistration and the [Extend Trial] button. 

 

starttrial03

 

There is used the advanced OLM to extend the trial period with a call to the OnlineExtendTrial() method using the following line:

 

OnlineExtendTrial(0);  //for module 0

 

Before the user can extend the trial period you must modify the appropriate record into the OLM making Extend = 'Y'. This may be accomplished from the control panel or from the RegMonitor utility.

 

From the control panel:

 

Select the appropriate record then click on the Extend [Y] button, as you can see below.

 

extendtrial01

 

From the RegMonitor:

 

Enter the appropriate values for Path, App ID, Encryption Key, InstallCode and Module, then click on the [Go] button. Then the matching record will be read and filled the field with its values. To enable the Extend field change the Extend ComboBox to Yes then click the [Save Data] button.

 

extendtrial03

 

Finally inform to the user that the trial period is ready to be extended.

 

HOW TO REGISTER THE APPLICATION USING A REGISTRATION KEY?

The following steps must be accomplished:

 

keygen01

1. The user send you the InstallCode. e.g. DF8ACE-DC468A-4561A5-FD2D61

 

2. Using this InstallCode you calculates the Registration Key through the KeyGen utility (see the left image).

There you enter the needed fields, the InstallCode received from the user and configure the key to be generated. In this sample the key is generated for the module 0 with one user and two instances authorized, the key will be of the Temporary type and authorized by 360 days starting at 10/06/2008 and Values = 730. The resulting key for the sample is: W71DYGJ-96H2FGP-YAKJ70D-M8R08V9

 

3. You send the key to the user. In this sample: W71DYGJ-96H2FGP-YAKJ70D-M8R08V9.

 

 

 

4. The user register the application using the key received from you using one of these two options: ONLINE and OFFLINE. In the Demo1 are implemented both options. 

 

registerkey01

 

a) ONLINE: The key and other registration data is saved into the local computer and also into the OLM database. Below is the code used on Demo 1 for this option:

 

procedure TRegForm.BtnRegClick(Sender: TObject);

var s: string;

begin

if not testfields(True) then exit; //test fields Username, Company, Email and Registration Key

writeData; //Write Username, Company and Email to the Local Application data before to register

//try to register the key and post data to the OLM

s:=Form1.AVLockS31.OnlineRegisterKey(trim(EdKey.Text));

if (s='50') then showmessage('Key registered successfully')

else showmessage('Registration Error: '+Form1.errormessage(s));

end;

 

b) OFFLINE: The key and other registration data is saved only into the local computer. Below is the code used on Demo 1 for this option:

 

procedure TRegForm.BtnReg2Click(Sender: TObject);

var err: integer;

   s:string;

begin

if not testfields(True) then exit; //test fields Username, Company, Email and Registration Key

writeData; //Write Username, Company and Email to the Local Application data before to register

 

err:=Form1.AVLockS31.RegisterKey(EdKey.Text); //try to register the key

case err of

   0: s:= 'Key registered successfully';

   1: s:= 'Key length mismatch';

   2: s:= 'Bad system date';

   3: s:= 'Registration was removed';

   4: s:= 'Invalid Registration Key';

   else s:= 'Unknown error';

end;

showmessage(s); //show operation result

end;

 

HOW TO REGISTER THE APPLICATION USING THE OLM?

 

Using the advanced set of scripts php (OLM) it is possible to register the application at temporary or definitive way using the method OnlineRenew() passing with parameters the advancedkeymanager.php script and the module number. The Demo1 implement it with the [Activate] button.

 

This way is only possible if the related record already exists in the OLM, previously created when started the trial period.  The user will be able to activate the new registration only if you previously change the related record and set Paid = 'Y', this could be accomplished with the control panel or with the RegMonitor utility.

 

OLM 3 Control Panel

regiserkey03

For this sample we use the control panel of the OLM 3 to enable the registration. For this case we configure it with user=1, instance=1, Values=730, Days=65535 (permanent). Then we click on the [Y] button to save these values.

 

Once the record is enabled, we inform to the user that the registration is able to be Activated. Then the user activate the new registration with the [Activate] button.

 

regiserkey02

 

Below is the code used for the [Activate] button:

 

procedure TRegForm.BtnRenewalClick(Sender: TObject);

var s:string;

begin

s:=Form1.AVLockS31.OnlineRenew(0);//try to renew the key for the module 0

if (s='00') then showmessage('Renewal Applied') else showmessage(Form1.AVLockS31.OlmError2Str(s));

end;

 

Into the OLM the script advancedkeymanager.php calculates the key according with the data into the record for the given module,  so in this sample this data will be (users=1, instances=1, days=65535 and Values=730) and return the key to the application, where  the key is finally registered and the key saved into the local registration data. With identical result that when the key is registered offline.

 

HOW TO RENT THE APPLICATION BY MONTH, YEAR, ETC?

 

Using one of the previous options register a temporary key for the wanted period.

 

WHAT IS A GENERIC KEY?

Normally a key is generated to be applied only for one computer where the InstallCode match with the one used to generates the key. But, if you check the "Generic key" checkbox, then will be generated a generic key which will serve to register any computer, but in this case limited to the same version, so if you change the version property in your application this key will not serve for this new version. This kind of key can be useful for massive registrations but for another use it is not recommended.

 

 

PART OF THE SOURCE CODE

 

Below is part of the source code where you can see the definition of a basic set of methods and properties that would be useful to  know before to use the component.

 

type

TRegStatus = (Unregistered, Moved, Expired, Registered);

TKeyType = (Trial, Temporal, Permanent, Unregister, UnregisterAll);

 

TModuleData = record

   Status       : TRegStatus;

   KeyType      : TKeyType;

   Startdate    : TDate;

   EndDate      : TDate;

   Days         : word;

   DaysLeft     : word;

   Users        : byte;

   Instances    : byte;

   Primary      : boolean;

   DateBacked   : boolean;

   TooManyInstances : boolean;

   Values       : string;

   Key          : string;

   //For secondary registration

   ICodeP       : string;

   InstallCodep : string;

end;

 

TInstallCodesources = set of (CPU_ID, HD_SN, Random_Code, User_Name, Other_Source);

 

 

TAVLockS3 = class(TComponent)

private

//published

FInstallCodeSources    : TInstallCodeSources;

FRegPath               : TRegPath; //Standard Special folder for local registration data

FOlmPath               : string; //Path for the OLM into the server  '/olm3'

FOlmBasicScript        : string; //PHP script for the Basic OLM  'basickeymanager.php'

FOlmAdvScript          : string; //PHP script for the Advan OLM  'advancedkeymanager.php'

FOlmCheckScript        : string; //PHP script for CheckDate OLM  'checkdate.php'

FRegFolder             : string; //Folder for the regdata file e.g. 'avlocks3' v3.0.2

FRegFilePath           : string; // Path for the RegData file

FAppName               : string; // Application name

FAppVersion            : string; // Application version

FEncryptionKey         : string;

FEncryptionKey2        : string;

FWebHost               : AnsiString; // Default www.av-soft.com

FAppID                 : word;    // Application ID

FInstancesCtrl         : boolean; // App Instances enabled

FDateWarning           : boolean; // Need to check the system date

FDateBacked            : boolean; // System date has been backed

 

//public

FInternetPort          : word;

FInternetFlag          : dword;

FUserName              : string; //user name

FCompany               : string; //company

FEmail                 : string; //user email

FICSources             : string; //string like '01101' to hold InstallCode Sources

FInstallCode           : string; //Install code, machine dependant calculated from several sources

FICode                 : string; //checksum from the FInstallCode to be included into keys

FRandomCode            : word;   // calculated and saved the first time the app runs

FOtherCode             : word;   //OtherCode must be entered at runtime before to call anything

FLastDate              : TDate;

FRemovableDisk         : boolean;

FFirstTime             : boolean;

FStarted               : boolean;

 

public

constructor Create(AOwner: TComponent); override;

procedure ReadLastDate;

function ReadAppData(update:boolean):boolean;

procedure WriteAppData;

procedure GetICode(var icode, installcode:string);

function CalcUserID(Uname:string):dword;

function DecodeRegKey(m,v,a:word;ic,RKey:string;var appid_modid, icod_ver,begindate,days:word;

        var modul,users, instances, keytype:byte; var values:string):integer;

function GenRegKey(Values, AICode:string; Abegindate:tdate; Adays,AAppID:word;

        AUsers, AInstances, Amodule, AKeyKind:byte):string;

function GenGenericKey(AiCode, Values:string; Abegindate:tdate; Adays,

        AVersionID,AAppID:word; AUsers, AInstances, Amodule, keytype:byte):string;

function GenRegularKey(AIcode, Values:string; Abegindate:tdate; Adays,

        AAppID:word; AUsers, AInstances, Amodule, keytype:byte):string;

function GetKeytype(Key:string):byte;

procedure MakeTrial(nmod,users,instances:byte; startdate:tdate; days:word);

procedure WriteLastDate;

function EraseReg:boolean;

function EraseMod(modul:byte):boolean;

function checkkey(m,v:word;ic,RKey:string):boolean;

function RegisterKey(Key:String):integer;

function IcodeSources2Str:string;

function Str2IcodeSources(s:string; var icsources:TInstallCodeSources):boolean;

function DecodeAppData(appdata:string; var icsources:TInstallCodeSources;

   var UsrNam,Comp,Eml,AppNam,AppVer,icsrc:string; var RanCod,OtherCod:word):boolean;

Function UserNameFromWindows: string;

Function IsLocal:boolean;

Procedure Start;

procedure restart;

function decodeicode(icode:string; var cod_name, cod_cpu, cod_hd, cod_rand, cod_other,checksum:word):boolean;

function ReadModule(nmod:byte):string;

function WriteModule(RKey:string):boolean;

function GetModule(nmod:byte; var ModData:TModuleData):boolean;

 

// INTERNET ROUTINES

function Connected:boolean;

function OnlineRequest(target:string; postdata, enkey2:AnsiString; web:string):AnsiString;

function OnlineRegisterKey(Key:String):string;

function OnlineStartTrial(nmod:word):string;

function OnlineExtendTrial(nmod:word):string;

function OnlineGetKeyB(values:string; kind, nmod, days, inst:word):string;

function OnlineGetKeyA(values:string; kind, nmod, days, startdate, usrs, inst:word):string;

function OnlineMovePrimary1(nmod:word):string;

function OnlineMovePrimary2(OldIcode:string; nmod:word):string;

function OnlineMoveSecondary1(nmod:word):string;

function OnlineMoveSecondary2(OldIcode:string; nmod:word):string;

function OnlineRestorePrimary(nmod:word):string;

function OnlineRestoreSecondary(nmod:word):string;

function Onlin