C++ Software Licensing

Hello World

To add license checking to a C or C++ application you include a single header file and put a library file in your execution path. You can then call the checkLicense method to load the license information and check that the user has a valid license. You need to specify a folder location for the license file, your developer password string, the license key issued to the user and the name of the application.

#include <pgslic.h>

int status = nuvovis::checkLicense(".", PWD, key, "Hello World");
if (status != nuvovis::LICENSE_OK) {
    throw runtime_error("Application not licensed");
}

Building the Example

The library download includes C++ example applications showing the use of the software licensing library with the developer password for the free test drive environment. For this step by step guide to building and running an example we will be using Visual Studio 2015 on a Windows development machine, and the test drive web portal environment to create licenses for our test application.

Download the Nuvovis package for Windows from the settings page and extract it to a work folder. Browse to the examples/HelloWorld folder and open the Visual C++ project file. Select x86 for 32-bit or x64 for 64-bit and build the project. The executable will be written to the bin folder (32-bit) or the bin64 folder.

Creating a License

The example cannot run until we have created a license for the application. In the web portal click on the New button to create a new Software License. Change the client field to one of the customer names and the product name to "Hello World". Save the new license to store the new license in Genux-B. The new Software License will now have a License Key field value. In the folder where the executable was written open the HelloWorld.ini file with a text editor and copy and paste the license key into the ini file and save the file.

Now our application is licensed and we can use it. Open a command window and run the HelloWorld executable. We should get a message and a license file in the current folder.

C:\Users\bob>cd Documents\nuvovis_2.0.1490\bin64

C:\Users\bob\Documents\nuvovis_2.0.1490\bin64>HelloWorld.exe
Hello World!

C:\Users\bob\Documents\nuvovis_2.0.1490\bin64>dir

 Directory of C:\Users\bob\Documents\nuvovis_2.0.1490\bin64

08/05/2016  15:44               698 1-9-549.lic
07/05/2016  12:16         1,859,072 HelloWorld.exe
07/05/2016  12:16         4,413,012 HelloWorld.ilk
08/05/2016  15:42                35 HelloWorld.ini
07/05/2016  12:16         8,237,056 HelloWorld.pdb
07/05/2016  11:32           772,608 PGSLIC.dll
07/05/2016  11:32           772,608 pgslicmd.dll
07/05/2016  11:32             7,184 pgslicmd.lib
07/05/2016  11:32           996,352 pgslicmt.dll
07/05/2016  11:32             7,184 pgslicmt.lib

Back in the web portal you can now see that the license has been used by clicking on the license id link in the license list view for the new Software License.