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.
Contents |
J2Play DRM Client
- Download the DRM client code here: Image:J2play-cpp-drm-client.zip
- Decompress the package
- Add DRMClient.cpp and DRMClient.h files to your game project
- Open DRMClient.cpp, modify the path of 'J2PlayGDKInc.h'
- If your game doesn't use "stdafx.h" as the precompiled header file, remove
#include "stdafx.h"
from DRMClient.cpp; add correct precompiled header file or header file you uses for window tokens.
Querying Current DRM
Use the following code to test if the current license is the Trial or Full license at the beginning of your game:
#include "DRMClient.h"
unsigned int result = J2Play::DRMClient::GetInstance()->Check();
if (result == J2Play::DRMClient::DRM_UNLOCK)
{
// TODO: Unlock your game here
}
else
{
// TODO: Lock your game here
// if result == J2Play::DRMClient::DRM_FAILURE,
// you can get the error message by J2Play::DRMClient::GetInstance()->GetMessage()
}
And use the following code to destroy DRMClient instance right before you shut down the GDK.
#include "DRMClient.h" J2Play::DRMClient::GetInstance()->Check(); CGDKInstance::GetInstance()->Destroy();
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.
