Activation API contains only 4 functions. Two for online activation and other two for offline activation when the computer has no access to the Internet. Activation API is intended to work in cooperation with Web License Manager, so a developer still should invoke licensing system API to use serial numbers obtained from WebLM.
The function passes 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 holds 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 put to.
This function passes a serial number to the server for deactivation. Possible return codes are listed below.
int VMProtectDeactivateLicense(const char *serial);
The serial parameters contains the serial number (not the activation code) obtained from WebLM earlier during activation.
These two functions work similar to the previous two, except they do not try to connect to the WebLM server. Instead, they return a text block that a user should copy to a computer connected to the Internet, 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 similar to those of the online version 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 copied to. Possible error codes are listed below.
Possible error codes
|ACTIVATION_OK||0||Activation is successful. The serial number is put 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 means some configuration issues on the server, wrong server URL or a hack 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 leaked or pirated). Not to be confused with ACTIVATION_ALREADY_USED.|
|ACTIVATION_CORRUPTED||5||Something has gone completely wrong. The error is produced by the activation module self-check system and usually means a hacking attempt. If you’ve got 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 database of the activation server. Perhaps, a user made a mistake while entering the code, so we can ask him or her to check if everything all right.|
|ACTIVATION_ALREADY_USED||7||The activation counter for this code is depleted and all further activations are impossible. This doesn’t mean the code is bad or banned. The code is good, but it just can’t be activated any more. The user should contact the software vendor and purchase additional licenses or uninstall the software on other computer to increase the value of the activation counter on the server.|
|ACTIVATION_SERIAL_UNKNOWN||8||Activation error. The given serial number is not found in the database on the server. Therefore, deactivation is impossible.|
|ACTIVATION_EXPIRED||9||Activation error. Means the activation period of the code has expired.|
|ACTIVATION_NOT_AVAILABLE||10||This error means activation/deactivation is unavailable.|
Tips and tricks
Activation API is pretty simple, so you shouldn’t experience difficulties with it. Do not forget to offer a way to activate the program offline for users who have problems with the Internet. Also, don’t forget, the Activation API does not save the serial number it receives and does not pass it to the licensing module – this should be done by the developer. You don’t have to call Activation API on every launch of the application. You just need to call it once, get a serial number from WebLM, save it where appropriate and then use this saved copy.