Quick Start — C++ Client Library

Prerequisites

Before you begin, make sure you have the following ready:

Download the Library

Download the latest version of the KEYZY C++ Client Library. Extract the zip file — you’ll find Include and Lib folders organized by platform and compiler. For details on the folder structure, see C++ Static Library Files and Folders.

Add to Your Project

Add the Include folder to your compiler’s header search path and the appropriate Lib folder to your library search path. Then link against KeyzyClient.

Visual Studio:

  1. Right-click your project → Properties
  2. C/C++ → Additional Include Directories → add the Include path
  3. Linker → Additional Library Directories → add the Lib path for your configuration (e.g. R64MDx64v143 for Release x64 with MD runtime on VS2022)
  4. Linker → Input → Additional Dependencies → add KeyzyClient.lib

Xcode:

  1. Build Settings → Header Search Paths → add the Include path
  2. Build Settings → Library Search Paths → add the Lib path (e.g. XcodeAppleSiliconIntel64)
  3. Build Phases → Link Binary With Libraries → add libKeyzyClient.a

CMake:

target_include_directories(your_target PRIVATE /path/to/KeyzyClientLibrary/Include)
target_link_directories(your_target PRIVATE /path/to/KeyzyClientLibrary/Lib/Ubuntu)
target_link_libraries(your_target KeyzyClient)

For a JUCE-specific setup, see the Add KEYZY to a JUCE Project tutorial.

Configure ProductData

Every operation in the library starts with a ProductData structure that identifies your product to the KEYZY service:

#include "KeyzyLicenseActivator.h"

Keyzy::ProductData productData(
    "YOUR_APP_ID",        // App ID from App Keys page
    "YOUR_API_KEY",       // API Key from App Keys page
    "YOUR_PRODUCT_CODE",  // Product Code from Products page
    "YOUR_CRYPTION_KEY"   // Encryption key for offline license verification
);

You can find your App ID and API Key on the App Keys page, and your Product Code on the Products page in the dashboard.

Note: These credentials are compiled into your binary. The KEYZY C++ Client Library is a static library specifically designed for this — unlike dynamic libraries, the communication and verification logic cannot be intercepted through API hooking. For additional binary-level protection, see ShieldVault on the platform page.

Create the Activator

Create the KeyzyLicenseActivator dynamically so you can share the validator and other internal objects across your application. The activator owns shared objects — like the license validator — that you’ll retrieve and pass to other parts of your code:

#include "KeyzyLicenseActivator.h"

// Create the activator dynamically — it owns shared objects used across your app
std::unique_ptr<Keyzy::KeyzyLicenseActivator> pActivator =
    std::make_unique<Keyzy::KeyzyLicenseActivator>(productData);

// Get the validator — you can store and use this anywhere in your application
std::shared_ptr<Keyzy::KeyzyLicenseValidator> pValidator =
    pActivator->getLicenseValidator();

Keep pActivator alive for the lifetime of your application. The validator and other shared objects reference internal state owned by the activator.

Activate a License

Semi-online activation is the most popular activation schema. It connects to the KEYZY server once to download an encrypted license file, then all subsequent validations happen locally — no internet required:

std::string serialNumber = "XXXX-XXXX-XXXX-XXXX"; // entered by the user

Keyzy::LicenseStatus status = pActivator->activateSemiOnline(serialNumber);

if (status == Keyzy::LicenseStatus::VALID)
{
    // License activated — unlock your application
}
else
{
    // Activation failed — see C++ License Status Codes reference
    // for all possible LicenseStatus values
}

The library stores the serial number and the encrypted license file on the device. On subsequent launches, you don’t need to ask the user for the serial again — just validate.

Offline License Life: You can set an Offline License Life for your SKU in the KEYZY dashboard (e.g. 30 days). When set, the downloaded license file expires after that period. Each time activateSemiOnline() is called and a new license file is downloaded, the timer resets. So if you set it to 30 days, your application should call activateSemiOnline() at least once every 30 days to renew the license file. The no-argument overload makes this easy — it re-downloads the license using the stored serial number, without asking the user again:

// Renew the license file silently — no serial number needed
Keyzy::LicenseStatus status = pActivator->activateSemiOnline();

Validate on Subsequent Launches

Once a license has been activated, use the validator to check it on every launch. For semi-online licenses, validation happens entirely offline using the stored license file:

Keyzy::LicenseStatus status = pValidator->validateOffline();

if (status == Keyzy::LicenseStatus::VALID)
{
    // License is valid — unlock your application
}
else
{
    // License is not valid — show the activation form
    // Common reasons: license expired, license file missing, etc.
}

You can also retrieve license details from the validator after a successful activation or validation:

std::string licensee = pValidator->getLicenseeName();
std::string sku      = pValidator->getSku();
std::string version  = pValidator->getVersion();

Next Steps

This tutorial covered semi-online activation — one of three activation schemas supported by the library. Explore the other schemas and features: