Create licenses for your installer and check them during installation: Part 3

I want to start these articles with a small disclaimer: This project is only meant for teaching purposes, this is not the most secure way to handle licenses in your installer. Ideally this must be handled from the application itself, not the MSI. Use at your own risk, I will not be held responsible for any “breaches” in your installers.

From my point of view, the best way to validate your product is to implement a check directly into the application and add the registration to be online. That way, you are sure that all the licenses you provide are secure on a database and breaches are less likely to occur.

 

In the first part of the series, we had a look over the license generator, in the second part we had a look on how a decrypt DLL for the MSI can be created, now let’s have a look on how you can actually use them in your MSI.

 

I opened up the license generator and generated a single key for the example:

 

This resulted in the following license key: 1444270299-1611014400

With this, I created a new project and added new Property in the MSI called LICENSEKEY. This will get the value that our generator created.

Then, we need to go to the Custom Actions page and add a new “Call function from attached DLL file” type of custom action. Remember from the second part that the function name is CheckMSILicense.

As a last step, we need to add a “Set Installer Property”. The property is the name of our previous custom action, and the value is the previously created Property:

If we build the MSI and try to install it, it will result in a success, because our license key is correct:

However, if we change the license key in something incorrect and try to install the MSI, we will be greeted with the message box which we implemented in the DLL in part 2 of the series:

I hope you find the series useful and maybe it helps you in your journey of licenses in MSI.

Part 1

Part 2

Sharing is caring!

Leave a comment

Your email address will not be published. Required fields are marked *

7 + 18 =