# Protect an Embarcadero C++ Builder app with QLM

This guide provides a step-by-step procedure to protect an Embarcadero C+ +Builder app. Note that the steps below assume you have a QLM License Server already setup.

1\. Launch the QLM Management Console

2\. Create a product from the “Define Product” tab or use the Demo 1.0 product if you are evaluating QLM.&#x20;

3\. Go to the "Protect your application tab":

* Page 1: Select the product to protect and the License Server
* Page 2: Select "C++ Builder"
* Page 3: Leave the default settings or customize the look & feel if needed. By default, QLM will bind the license to the Computer Name. You can select the binding of your choice by setting the [QlmLicenseBinding](https://support.soraco.co/hc/en-us/articles/360001183583-QlmLicense-LicenseBinding) property located in the section "6. Qlm License Properties".
* Page 4: Select the folder where your project source code is located and click Save.
* Page 5: Click Finish

4\. Open your C++ Builder project in RAD Studio

5\. Copy the following files to your project's folder:

* C:\Program Files\Soraco\QuickLicenseMgr\Redistrib\\.net 4.0\QlmLicenseLib.dll
* C:\Program Files\Soraco\QuickLicenseMgr\Redistrib\\.net 4.0\QlmLicenseWizard.exe

6\. Add the following files to your project:

* LicenseValidator.cpp/h
* mscoree\_TLB.cpp/h
* mscorlib\_TLB.cpp/h
* QlmLicenseLib\_TLB.cpp/h

7\. The files QlmLicenseLib.dll, QlmLicenseWizard.exe and the XML settings file must be configured to be deployed to the same folder as your executable.

8\. In your app's module where you want to add license validation, add the following code:

* Add the following statement:
  * \#include "LicenseValidator.h"
* Declare the following variables&#x20;
  * UnicodeString qlmWizard;
  * UnicodeString settingsFile;
  * UnicodeString wizardArgs;
  * TLicenseValidator\* lv;
* *Declare the following function in the header file of your app's module:*
  * int \_\_fastcall DisplayLicenseForm();

9\. Add the code similar to the code below where you want to perform the license validation. Modify the class name below (TAppForm) to match your own class.

{% code overflow="wrap" %}

```cpp
void __fastcall TForm1::FormCreate(TObject *Sender)
{
    lv = new TLicenseValidator();
    bool needsActivation=false;
    UnicodeString errorMsg=L"";
    // Example of getting a unique identifier
    IQlmHardware *qlmHardware = lv->CreateQlmHardwareObject();
    UnicodeString computerID=qlmHardware->GetMachineName();
    ELicenseBinding licenseBinding=ELicenseBinding::ELicenseBinding_ComputerName;
    settingsFile = ExtractFilePath(Application->ExeName) + L"Demo 1.0.lw.xml";
    qlmWizard = ExtractFilePath(Application->ExeName) + L"QlmLicenseWizard.exe";
    wizardArgs = L" \/settings \"" + settingsFile + "\"";
    // If you use a LicenseBinding of type UserDefined, you must pass the computerID
    // wizardArgs := '/settings "' + settingsFile + '" /computerID ' + computerID;
    bool licenseValid=lv->ValidateLicenseAtStartup(licenseBinding, needsActivation, errorMsg);
    if (needsActivation || (licenseValid==false))
    {
        DisplayLicenseForm();
        if (lv->ValidateLicenseAtStartup(licenseBinding, needsActivation, errorMsg) == false)
        {
            Application->Terminate();
        }
    }
}
int __fastcall TForm1::DisplayLicenseForm()
{
    CComBSTR pName(wcslen(qlmWizard.c_str()));
    wcscpy(pName.m_str, qlmWizard.c_str());
    CComBSTR pArgs(wcslen(wizardArgs.c_str()));
    wcscpy(pArgs.m_str, wizardArgs.c_str());
    return lv->QlmLicenseObject()->LaunchProcess(pName, pArgs, true, true);
}
```

{% endcode %}

This completes the integration. The next time you open your Delphi application the ValidateLicenseAtStartup method should get triggered and perform the license validation.&#x20;

To generate a license key for testing purposes:

* Go to the Manage Keys tab.
* Click "Create Activation Key"
* Select the Product (Demo 1.0 for trials) and click OK.
* Copy and Paste the generated Activation Key in the License Wizard launched when your application starts up and follow the steps in the wizard.

The files that you need to distribute with your application are:

* QlmLicenseLib.dll
* QlmLicenseWizard.exe
* XML file generated by the Protect Your Application Wizard


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.soraco.co/docs/step-by-step-guides/protect-an-embarcadero-c++-builder-app-with-qlm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
