How to activate a license programmatically from VC++

Following is a code excerpt that shows how to activate a license programmatically from VC++.

The code below assumes that you have an instance of a LicenseValidator class (generated by the Protect Your Application wizard). m_lv refers to the instance of the LicenseValidator class. In this example, we will bind the license to the computer name.

CComBSTR bstrResponse;
_bstr_t("AFGQ0-E0400-G7JBI-Z86H4-1B1W7K"), m_lv->hardware->GetMachineName(), m_lv->hardware->GetMachineName(), _bstr_t("5.0.00"),
_bstr_t("user data1"), &bstrResponse);

CComBSTR bstrMessage;
if (m_lv->license->ParseResultsEx (_bstr_t(bstrResponse), m_lv->licenseInfo, &bstrMessage))
    CString pckey = m_lv->licenseInfo->ComputerKey;
    MessageBox (QlmLicenseWizardDlg::s_hwndDialog, (LPCWSTR) (m_lv->licenseInfo->ComputerKey), _T("QlmLicenseWizard"), MB_OK);
    MessageBox(QlmLicenseWizardDlg::s_hwndDialog, CString(bstrMessage), _T("QlmLicenseWizard"), MB_OK);

Last updated