Now that you have defined a license policy, you need a license template to integrate LM-X with your application.
To generate an XML license template:
- Create a template of the license you are interested in.
- Run the license generator provided with LM-X, xmllicgen, as described in Generating licenses.
In the following example we assume the license will expire on January 1, 2018. This license defines one feature with version 1.0.
Run xmlicgen to convert the above LM-X license template to a license file.
The resulting file will be license.lic. Xmllicgen will automatically replace your ".xml" extension with ".lic" and save the license next to your template.
First of all, you must include the required header, lmx.h, located in the include directory of your SDK.
If your project and LM-X SDK are in separate directories, remember to specify the include directory for your compiler. For example:
Commonly used functions
In the following examples we will present five commonly used LM-X API functions.
The LMX_Init function initializes the protection system. This function creates a handle needed to use other LM- X API functions. It returns LMX_STATUS variable that indicates initialization status.
The LMX_SetOption function sets up flags that change licensing behavior prior to license checkout. This function returns LMX_STATUS variable that indicates the status of initialization.
In the following example LMX_SetOption is used to set the license path to the current path.
The LMX_Checkout function is one of the most important LMX API functions, because it checks out one or more licenses for a specific feature. This function requires that the feature name, version and the count of the features be defined as shown below.
The LMX_Checkin function returns the licenses for a single checked out feature or all checked out features.
Making it work
The following example illustrates a complete, compiled example that includes source code necessary to license your application using LM-X License Manager.
If you decide to copy and paste the above code block, save it as an
Let's assume you saved your program source code as an
example.c and installed your LM-X SDK in the default directory.
To compile your first program run the following:
Running your application
Your current directory should include the files listed in the table below.
|license.xml||Your license template.|
|license.lic||Ready to use license, generated with xmllicgen.|
|example.c||Your first program source code.|
|example/example.exe||Your program executable.|
Now run your first LM-X licensed application.