AX: Advanced Licensing Sample

Project name: AdvLic

The advanced licensing sample shows how to fully customize your software licensing algorithm. Note that EZ Trial implements the most common PLUS features with the fewest lines of code and may be a better alternative to this project. Refer to the sample project EZTrial1 instead. The AdvLic project demonstrates:

Modules/forms/files in project

PPPFunc – module that contains Declare statement for a Windows API function GetWindowsDirectory which is used for the location of the License File Alias.

frmMain – form that simulates your application. This form has several menu options that simply display message boxes.

frmUnlock – form displayed when the user needs to enter a Trigger Code. This is a customizable form. When a valid Trigger Code is entered, the StatusChanged routine is called to re-evaluate the mode of the application.

sample.ini – license file that contains the expiration and copy protection information.

Select Product Definition in LFEdit

Run LFEdit from Start / Programs / SoftwareKey Licensing System / PLUS. If using an evaluation copy, change the product name in the toolbar combo box to AdvLic. If this is not in your list, go to Tools / Options and select Use Sample Definitions. When done experimenting with the sample applications, be sure to change this setting back to Use My Product Definitions.

Create a License File in LFEdit

In LFEdit, click the New button on the toolbar. Click on the Expiration Fields Tab. Change the Expiration type to None and the Hard Expiration Date to 0/0/0. This will set the expiration date to 30 days from the date the application is first run on the computer. Alternatively, you could pre-define the expiration date by changing the Expiration Type to Demo or Periodic and setting the Hard Expiration Date to the desired value. This sample application does not use the Soft Expiration Date field. Be sure to save the License File in the directory where your application is stored.

Run Your Application

The PLUS ActiveX component is located on the Main Form of the application. When this form is loaded, the Computer ID algorithm is set along with the License File name and password. The License File Alias is set up to use the file AdvLic.ini in the Windows directory. You can set up as many aliases in various locations as you desire. The StatusChanged event will fire right after the LFAlias method is called and the License File Alias is opened.

The StatusChanged event contains the entire license checking logic. This event is fired whenever the status changes from one mode to another (such as application startup and when a valid Trigger Code is entered). Before the application displays the main form, the copy protection test and demo expiration test is run. If the copy protection test passes and the expiration type is set to "P" for Periodic, the expiration test is executed because the application is in the Periodic expiration mode (the software license must be renewed quarterly). If the copy protection test fails and the expiration type is set to "D" for Demo, the expiration test is also executed. Different messages are displayed depending on the mode of the application. The Next Payment due or Demo Expires indicator is displayed (if applicable) and the menu options are enabled depending on the mode (valid demo, expired demo, or retail version). If the software is copied onto an unauthorized computer, it will be converted back into a demo.

Activate the Application Using Trigger Codes

Click on the File / Enter Activation Code menu option added to display the Trigger Code dialog. Write down the two numbers on the form. These two numbers are what your customer will give you by phone, fax, or e-mail. Run LFEdit. With the correct Product Definition selected in the toolbar, click on the Trigger Codes button (lock) on the toolbar. The following Trigger Codes are implemented in this custom Trigger Code dialog box:

Experiment with each of the codes to verify the desired result. Choose the code desired and click Select. Enter the two numbers previously written down and click Generate. Write this number down. This is the unlock code that will be given to the customer. Minimize LFEdit and enter this code into the application. You should see the "Activation Complete" message appear. This is when the StatusChanged event will fire and the main form will update the indicators and menu options depending on the new mode.

For all sample applications, the License File password used is password, the Trigger Code Event ID seed (RegKey1) is 400 and the Trigger Code Event Data seed (RegKey2) is 123.

This sample application will NOT create the License File automatically if it doesn't exist. This is because we will ship a License File with a hard expiration date embedded in it and we don't want to allow the user to keep deleting the License File to gain additional usage of the product.

Concept Link IconRelated Topics