How to create a trial key from within your application

The CreateComputerBoundTrialKey API creates a trial activation key, then automatically activates it on the server side and returns the computer bound license key. This function is useful if you want to create trial keys from within your application. The trial period is controlled by the trialDuration Server Property.

Server Properties can be set from the Manage Keys / Sites / Server Properties page. Before calling this function, you must call DefineProduct and set the CommunicationEncryptionKey property.

If you want to prevent calls to this function, set the enableCreateComputerBoundTrial Server Property to false. The Server Properties can be set from the Manage Keys / Sites / Server Properties page.

C#: string CreateComputerBoundTrialKey(string webServiceUrl, string computerID, string computerName, string email, string features, string affiliateID, string userData1, out string response)

Parameters webServiceUrl - URL to the QLM Web service.

computerID- Unique identifier of the computer being activated.

computerName - Friendly name of the computer being activated.

email - email address to associate with the license key - may be empty

features - Semi comma-separated list of feature sets and their corresponding values.

  • Example: 0:1;1:2;2:3;3:7

    • Enables feature 1 in feature set 0,

    • Enables feature 2 in feature set 1

    • Enables feature 1 + 2 (3) in feature set 2

    • Enables features 1 + 2 + 4 (7) in feature set 3.

affiliateID - ID of affiliate

userData1 - user data to associate with this license

response - XML fragment containing the result of the call. The Xml fragment schema is as follows: <?xml version='1.0' encoding='UTF-8'?> <QuickLicenseManager> <pckey>C06C4C90A497F091C2F080501000C076A0578E</pckey> <userCompany>My Company</userCompany> <userFullName>John Smith</userFullName> <userEmail>john@smith.com</userEmail> </QuickLicenseManager>

Return value: The returned value is the computer-bound license key (ComputerKey)

In order to associate a customer with a trial key, you can publish user information using the AddUser / AddUserEx functions.

C# Example:

// Assuming wizardSettingsFile is the path to the xml settings file 
// generated by the Protect Your Application wizard

QLM.LicenseValidator lv = new QLM.LicenseValidator(wizardSettingsFile);
string response;
string computerKey = lv.QlmLicenseObject.CreateComputerBoundTrialKey(string.Empty,
                                Environment.MachineName, Environment.MachineName,
                                string.Empty, string.Empty, string.Empty, 
                                string.Empty, out response);
string message = string.Empty;
ILicenseInfo licenseInfo = new LicenseInfo();

if (lv.QlmLicenseObject.ParseResults (response, ref licenseInfo, ref message))
{
    string ak = licenseInfo.ActivationKey;
    string ck = licenseInfo.ComputerKey;
    lv.QlmLicenseObject.StoreKeys(ak, ck);
}
 

VC++ Example:

// Assuming wizardSettingsFile is the path to the xml settings file generated 
// by the Protect Your Application wizard

LicenseValidator *m_lv = new LicenseValidator (wizardSettingsFile);

_bstr_t machineName = m_lv->hardware->GetMachineName();

_bstr_t computerKey = m_lv->license->CreateComputerBoundTrialKey(_bstr_t(""), 
                            machineName, machineName,
                            _bstr_t(""), _bstr_t(""), _bstr_t(""), 
                            _bstr_t(""), &bstrResponse);

CComBSTR bstrMessage;
if (m_lv->license->ParseResultsEx(_bstr_t(bstrResponse), m_lv->licenseInfo, 
                                           &bstrMessage))
{

    _bstr_t ak = m_lv->licenseInfo->ActivationKey;
    _bstr_t ck = m_lv->licenseInfo->ComputerKey;

    m_lv->license->StoreKeys(ak, ck);
}

Last updated