Home » Support » User Manual » The Software Licensing System » Activation System » Activation API

Activation API

There are 4 API functions in the Activation API. Two for online mode and two for offline. Activation API is about dealing with the Web License Manager, you still need the Licensing API to set up the serial numbers.

VMProtectActivateLicense

Function passes the activation code to the server and returns the serial number for that exactly installation. Otherwise it returns the error code.

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

Parameter code contains the activation code that is provided by the Web License Manager during the order process. The serial parameter points to the memory block of size size, enough to hold the serial number.

VMProtectDeactivateLicense

Function passes the serial number to the server for deactivation. See the possible return codes to check the result of deactivation.

INT __stdcall VMProtectDeactivateLicense(const char *serial);

Parameter serial contains the serial number (not the code) obtained from the server during the activation process.

VMProtectGetOfflineActivationString
VMProtectGetOfflineDeactivationString

These two functions work pretty much the same way as the online ones above, but they don’t try to connect the server. Instead, they return a “magic” string that needs to be copy-pasted to the web browser, showing the Web License Manager offline activation page.

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

The code and serial parameters are the same as in the functions above, the buf parameter should be about 1000 characters and receives a null-terminated text string that needs to be copied by the user. See the possible error codes here.

The possible return codes

Flag Value Description
ACTIVATION_OK 0 Activation successful, the serial field contains a serial number.
ACTIVATION_SMALL_BUFFER 1 The serial number buffer is too small. The formula for the buffer size is: bits / 8 * 3 / 2 + N, where bits is the length of your RSA key and N is a “safety” buffer that should be at least 10.
ACTIVATION_NO_CONNECTION 2 The activation module was unable to connect the Web License Manager.
ACTIVATION_BAD_REPLY 3 The server returned unexpected reply. This means configuration problems or probably a cracking attempt.
ACTIVATION_BANNED 4 The activation code is blocked on the server. This doesn’t mean that the number of possible activations is exceeded, this means that this exactly code is banned by the vendor, so the user is trying to cheat you.
ACTIVATION_CORRUPTED 5 Something goes really wrong here. The error means that the internal activation stuff is not working, it is not safe to continue with the activation, registration and so on.
ACTIVATION_BAD_CODE 6 The code has been successfully passed to the server and it was unable to find it in the database. Probably the user made a mistake, so it is worth asking the user to check the entered code for mistakes.
ACTIVATION_ALREADY_USED 7 The code has been used too many times and cannot be used more. This doesn’t mean the code is bad or banned, it is OK. The user may contact vendor to ask/purchase more activations, or the user may deactivate some installations to increase the number of activations available for that code.
ACTIVATION_SERIAL_UNKNOWN 8 This is the deactivation error code that means that the server can’t find the serial number that the user tries to deactivate.

Tips and tricks

The Activation API is quite straightforward, so it shouldn’t be difficult to use it. Do not forget to provide an offline mode for the users, so they can activate the software even without the Internet access. Please also note, that the Activation API neither stores the serial number nor passes it to the licensing module. This is up to the developer to do this. It is not necessary to call the Activation API every time the application starts, call it once and then use the serial number and the licensing API.