# 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 %}


---

# 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/faq/how-to-activate-a-license-programmatically-from-vc++.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.
