Get Demo
  • Windows
  • MacOS
  • Linux

Activation API

The Activation API contains only four functions. Two are for online activation and two are for offline activation when the computer has no access to the Internet. The Activation API is intended to work together with Web License Manager, so a developer still needs to invoke the licensing system API to use serial numbers obtained from WebLM.

VMProtectActivateLicense

This function sends the activation code to the server and returns a serial number for this specific computer. Otherwise, an error code is returned.

int VMProtectActivateLicense(const char *code, char *serial, int size);

The code parameter contains the activation code obtained from Web License Manager during the license purchase process. The serial parameter specifies a memory block of the given size, where the serial number generated by WebLM is written.

VMProtectDeactivateLicense

This function sends a serial number to the server for deactivation. Possible return codes are listed below.

int VMProtectDeactivateLicense(const char *serial);

The serial parameter contains the serial number (not the activation code) obtained from WebLM during activation.

VMProtectGetOfflineActivationString

VMProtectGetOfflineDeactivationString

These two functions work similarly to the previous ones, except they do not attempt to connect to the WebLM server. Instead, they return a text block that the user should copy to a computer with Internet access, open the WebLM offline activation form, and paste the text there.

int VMProtectGetOfflineActivationString(const char *code, char *buf, int size);
int VMProtectGetOfflineDeactivationString(const char *serial, char *buf, int size);

The code and serial parameters are the same as in the online versions of these functions. The buf parameter should point to a buffer of 1000 bytes or more, where the text block for the offline activation form will be written. Possible error codes are listed below.

Possible error codes

Code Value Description
ACTIVATION_OK 0 Activation is successful. The serial number is written to the serial variable.
ACTIVATION_SMALL_BUFFER 1 The buffer is too small to hold the serial number. The minimum buffer size is calculated as: bits / 8 * 3 / 2 + N, where bits is the length of the RSA key in bits, and N is a “security constant” — additional bytes for possible line breaks and other special symbols. We recommend using at least 10.
ACTIVATION_NO_CONNECTION 2 The activation module couldn’t connect to Web License Manager.
ACTIVATION_BAD_REPLY 3 The activation server returned an unexpected result. This usually indicates server configuration issues, an incorrect server URL, or a tampering attempt.
ACTIVATION_BANNED 4 This activation code is banned on the server by the software vendor via the WebLM interface (for example, if the key has been leaked or pirated). Not to be confused with ACTIVATION_ALREADY_USED.
ACTIVATION_CORRUPTED 5 Something has gone completely wrong. This error is produced by the activation module self-check system and usually indicates a tampering attempt. If you receive this error, all further operations with serial numbers and activation are not safe.
ACTIVATION_BAD_CODE 6 The specified code is not found in the activation server database. The user may have mistyped the code, so they should be prompted to check it.
ACTIVATION_ALREADY_USED 7 The activation counter for this code is depleted and no further activations are possible. This does not mean the code is invalid or banned. The user should contact the software vendor or free up activations by uninstalling on other devices.
ACTIVATION_SERIAL_UNKNOWN 8 Activation error. The given serial number is not found in the server database, so deactivation is impossible.
ACTIVATION_EXPIRED 9 Activation error. The activation period of the code has expired.
ACTIVATION_NOT_AVAILABLE 10 This error means activation or deactivation is currently unavailable.

Tips and tricks

The Activation API is relatively simple, so it should not cause difficulties. Make sure to provide an offline activation option for users who have Internet connectivity issues. Also, note that the Activation API does not save the serial number it returns and does not pass it to the licensing module — this must be handled by the developer. You do not need to call the Activation API on every application launch. You only need to call it once, obtain a serial number from WebLM, store it appropriately, and then use the saved copy.

Last updated 11 days ago