Cryptlex Documentation
  • Welcome to Cryptlex!
  • Getting Started
    • Overview
    • Licensing Models
  • License Management
    • License Templates
    • Implementing License Models
    • Custom License Fields
    • Meter Attributes
    • Creating Licenses
    • Renewing Licenses
    • Extending Licenses
    • Suspending Licenses
    • Revoking Licenses
    • Maintenance Policies
  • User Management
    • Roles
    • Creating Users
    • Authenticating Users
    • Organizations
    • Resellers
    • Customer Portal
    • Reseller Portal
    • Google SSO
    • SAML SSO
  • Feature Management
    • Overview
    • Feature Flags and Product Versions
    • Use Cases
    • Creating Product Versions
  • Release Management
    • Overview
    • Creating Releases
    • Distributing Releases
  • Node Locked Licenses
    • Overview
    • Using LexActivator
      • Using LexActivator with C, C++ and Objective C
      • Using LexActivator with C#
      • Using LexActivator with VB.NET
      • Using LexActivator with Java
      • Using LexActivator with Delphi
      • Using LexActivator with Python
      • Using LexActivator with Go
      • Using LexActivator with Node.js
      • Using LexActivator with Ruby
      • Using LexActivator with Android
      • Using LexActivator with iOS
      • Using LexActivator with Flutter
    • Using Web API
    • Offline Activations
    • Proxies and Firewall
  • Floating Licenses
    • Overview
    • Hosted Floating License Server
    • On-Premise Floating Licenses
      • LexFloatServer
      • Using LexFloatClient
        • Using LexFloatClient with C, C++ & Objective C
        • Using LexFloatClient with C#
        • Using LexFloatClient with VB.NET
        • Using LexFloatClient with Java
        • Using LexFloatClient with Delphi
        • Using LexFloatClient with Python
        • Using LexFloatClient with Node.js
        • Using LexFloatClient with Go
        • Using LexFloatClient with Android
        • Using LexFloatClient with iOS
      • Offline Floating License
  • Named User Licenses
  • Timed Trials
    • Verified Trials
    • Unverified Trials
  • Licensing Docker Apps
  • Webhooks
  • Automated Emails
  • Web Integration
    • Personal Access Tokens
    • Using Web API
    • Using Zapier
    • Using FastSpring
    • Custom Development
  • Changelog
    • Web API
    • LexActivator
    • LexFloatClient
    • LexFloatServer
  • Legal
    • Terms of Service
    • Privacy Policy
    • Subprocessors
    • Data Processing Addendum
    • Service Level Agreement
    • Security, Privacy, and Compliance
    • Open Source Licenses
  • Cryptlex On-Premise
    • Overview
    • System Requirements
    • Server Layout
    • Installation Guide
      • Docker Compose
      • Kubernetes
    • Configuring Client Libraries
    • Monitoring and Error Reporting
Powered by GitBook
On this page
  • Adding licensing to your app
  • Adding the library to your app
  • Setting product.dat file and product Id
  • License activation
  • Verifying license activation
  • Need more help
  1. Node Locked Licenses
  2. Using LexActivator

Using LexActivator with Delphi

PreviousUsing LexActivator with JavaNextUsing LexActivator with Python

Last updated 6 months ago

First of all, login to your Cryptlex account and download the LexActivator library for Windows or macOS:

  • ​​

  • ​​

The above download package contains the library which you will be using to add licensing to your app.

Adding licensing to your app

After you've added a product for your app in the admin portal, you will need to do the following things:

  • Note the product id for the product (from the actions menu in the table).

  • Download the Product.dat for the product (from the actions menu in the table).

  • Download the example project from

Product.dat contains product data that is used by LexActivator. The product id is the identifier of your product that is to be used in the code.

Adding the library to your app

LexActivator example project for Delphi (7 or newer) contains the LexActivator.pas unit file. In addition to that, it includes LexActivator.DelphiFeatures.pas unit file used internally.

You need to add these files to your app in order to use LexActivator API in your app. Both units must be added, but only the LexActivator unit must be added to the uses list. Depending on the OS you are targeting you need to copy the respective LexActivator.dll, libLexActivator.so, or libLexActivator.dylib to your project.

LexActivator has a dependency on VS2015 runtime on Windows. On the target machines where you will deploy your app, you can install the VS2015 runtime, if not present, using the link:

Setting product.dat file and product Id

The first thing you need to do is either embed the Product.dat file in your app using LexActivator.SetProductData function or set the absolute path of the file using LexActivator.SetProductFile function.

The next thing you need to do is to set the product id of your application in your code using LexActivator.SetProductId function. It sets the id of the product you will be adding licensing to.

SetProductData('PASTE_CONTENT_OF_PRODUCT.DAT_FILE');
SetProductId('PASTE_PRODUCT_ID', lfUser);

If your app requires admin (root) privileges to run (e.g. services, daemons etc.), instead of passing lfUser flag, you need to pass lfSystem flag.

If your app requires a single activation to be shared across all OS users (system-wide activation), pass the lfAllUsers flag before activation. This flag is compatible with Windows OS only.

In case your app doesn't have write access to the disk, you can use lfInMemory flag instead, which causes all the data to be stored in the memory. But this would require you to activate the license every time you restart the app.

License activation

To activate the license in your app using the license key, you will use LexActivator.ActivateLicense LexActivator API function. It invokes the /v3/activations Cryptlex Web API endpoint, verifies the encrypted and digitally signed response to validate the license.

var
  Step: string;
  Status: TLAKeyStatus;
begin
  try
    Step := 'SetLicenseKey'; SetLicenseKey('PASTE_LICENSE_KEY');
    Step := 'ActivateLicense'; Status := ActivateLicense;
    case Status of
      lkOK: ShowMessage('Activation successful!');
      lkExpired: ShowMessage('Activation successful, but license validity has expired!');
    else
      ShowMessage('Error activating the product: ' + LAKeyStatusToString(Status));
    end;
  except
    on E: Exception do
    begin
      ShowMessage('Exception from ' + Step + ': ' + E.ClassName + ': ' + E.Message);
    end;
  end;
end;

The above code should be executed at the time of license activation, ideally on a button click.

Verifying license activation

Each time, your app starts, you need to verify whether your license is already activated or not. This verification should occur locally by verifying the cryptographic digital signature of activation. Ideally, it should also asynchronously contact Cryptlex servers to validate and sync the license activation periodically. For this, you need to use LexActivator.IsLicenseGenuine LexActivator API function.

var
  Step: string;
  Status: TLAKeyStatus;
begin
  try
    Step := 'SetProductData'; SetProductData('PASTE_CONTENT_OF_PRODUCT.DAT_FILE');
    Step := 'SetProductId'; SetProductId('PASTE_PRODUCT_ID', lfUser);
    Step := 'IsLicenseGenuine'; Status := IsLicenseGenuine;
    case Status of
      lkOK: ShowMessage('License is genuinely activated!');
      lkExpired: ShowMessage('License is genuinely activated, but has validity has expired!');
      lkGracePeriodOver: ShowMessage('License is genuinely activated, but grace period is over!');
    else
      ShowMessage('Error code: ' + LAKeyStatusToString(Status));
    end;
  except
    on E: Exception do
    begin
      ShowMessage('Exception from ' + Step + ': ' + E.ClassName + ': ' + E.Message);
    end;
  end;
end;

The above code should be executed every time user starts the app. After verifying locally, it schedules a periodic server check in a separate thread. LexActivator.SetLicenseCallback can be used to set notification callback.

Need more help

In case you need more help with adding LexActivator to your app, we'll be glad to help you make the integration. You can either post your questions on our or can contact us through .

Download LexActivator for Windows
Download LexActivator for macOS
Github
https://www.microsoft.com/en-in/download/details.aspx?id=48145
support forum
email