> For the complete documentation index, see [llms.txt](https://docs.soraco.co/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.soraco.co/docs/faq/how-to-activate-a-license-programmatically-from-vc++.md).

# 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.

{% code overflow="wrap" %}

```cpp
CComBSTR bstrResponse;
m_lv->license->ActivateLicense(_bstr_t("
https://qlm3.net/qlmdemo/qlmLicenseServer/qlmservice.asmx
"),
_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);
}
else
{
    MessageBox(QlmLicenseWizardDlg::s_hwndDialog, CString(bstrMessage), _T("QlmLicenseWizard"), MB_OK);
}
```

{% endcode %}
