C++ LincenseCheck
From J2Play
To protect your program we suggest using the ArmAccess.dll API provided by SoftwarePassport/Armadillo in addition to the SoftwarePassport/Armadillo Environment variable detection. Full documentation is given in the SoftwarePassport/Armadillo download in the 'SoftwarePassport/Armadillo API'. The Armadillo Free Trial can be used to test with and to obtain all documentation/dlls and modify and test your code; however the final DRM wrapping must be done by us before the application is published so that it can interact with the J2Play purchase environment.
Querying Current DRM
The current DRM State can be determined by querying environment variables.
Use the following code to test if the current license is the Trial or Full license:
char username[255];
if (!GetEnvironmentVariable("ALTUSERNAME", username, sizeof(username))) {
printf("Game is not Wrapped");
} elseif (stricmp(username, "DEFAULT")) {
printf("Game is REGISTERED");
} else {
printf("Game is in TRIAL mode");
}
Managing DRM State
Since you want your Trial license to expire after a certain number of minutes of gameplay, you will want to keep track of this Time Period yourself, and then store it in the certificate itself so that it persists between installations and circumvents attempts to change the value. Once the total play time has exceeded your maximum (60 minutes) you will want to stop allowing the user to play.
Steps:
- Keep track of the length of game play in an internal timer.
- After each level, store the total length of game play using ArmAccess.dll setUserString(0,playTime);
- Before playing each level, query getUserString(0) to determine if play time has exceeded the maximum, and if it has and the user is using a Trial Key, discontinue game play.
