Using TurboActivate with Delphi
Before you can do anything you need to login to your LimeLM account (or sign up) and download the TurboActivate.zip. This zip contains the TurboActivate.dll & TurboActivate.exe along with source code examples.
After you've created a new product, go to the version page of the product you will be adding licensing to. You will need to do 2 things:
- Download the TurboActivate.dat file for the product version.
- Make a note of the Version GUID.
You'll be including the TurboActivate.dat file in the same folder as the TurboActivate.dll and TurboActivate.exe files and you'll use the Version GUID in your code as part of integrating TurboActivate within your app.
Included in TurboActivate.zip is a simple example project. It works with Delphi 7 and newer. The TurboActivateUnit.pas file contains all the functions you'll be using to add licensing, online-activation, and trial functionality to your app.
Fix Delphi's exception settings
Delphi XE (released 2011) and all newer versions are misconfigured. In Delphi, you need to go to "Tools" menu, click "Options", and scroll down to the "Debugger Options -> Embarcadero Debuggers -> Native OS Exceptions" and change 2 settings. First, under the "32-bit Windows OS Exceptions", change the "Privileged Instruction" to be handled by "User program". Next, under the "64-bit Windows OS Exceptions", again, change the "Privileged Instruction" to be handled by "User program":
If you don't do this, then when you run your app under the debugger you'll get exceptions that will crash your app. Why? Because the way TurboActivate works is that it throws exceptions and then catches them internally. However, with Delphi's default value of the "Debugger" handling the "Privileged Instruction", the Delphi debugger interrupts TurboActivate's default behavior with no real benefit other than to annoy and confuse you. This is a poor design choice on Embarcadero's part.
You must set the
TurboActivate.VersionGUID property before you use any TurboActivate functions. We recommend you set the VersionGUID property when your application first loads. You only need to set it once:
procedure TForm1.FormCreate(Sender: TObject); var ta : TurboActivate; begin ta.VersionGUID := 'Version GUID you copied earlier'; end;
IsActivated(), IsGenuine(), IsGenuineEx()
There are 3 separate TurboActivate functions for checking whether a customer is activated or not:
IsActivated()checks if the user is activated without contacting any servers (no internet connection needed ever). It does this by verifying the cryptographically signed "computer fingerprint".
IsGenuine()contacts the LimeLM servers to see if the user is still activated (checks for revoked product keys, etc.) and whether features have changed. This function requires an active internet connection to succeed (or else you get a TA_E_INET return code).
IsGenuineEx()is a mix of the best parts of
IsGenuineEx()you can specify how often to check with the LimeLM servers and all other times it verifies the activation locally. (Note: in Delphi
IsGenuine()function with the 4 parameters.)
For most cases we recommend using
IsGenuineEx(). For example:
//These 2 variables defined in a "var" section // isActivated : Boolean; // gr : IsGenuineResult; Try // Check if we're activated, and every 90 days verify it with the // activation servers. In this example we won't show an error if // the activation was done offline. (see the 3rd parameter of // the IsGenuine() function) gr := TurboActivate.IsGenuine(90, 14, true); isActivated := (gr = Genuine) or (gr = GenuineFeaturesChanged) // an internet error means the user is activated but // TurboActivate failed to contact the LimeLM servers or (gr = InternetError); except on E : Exception do ShowMessage('Failed to check if activated: ' + E.Message); end; If isActivated Then ' your app is activated and genuine if gr = InternetError then begin //TODO: give the user the option to retry the genuine // checking immediately. For example a dialog box. // In the dialog call IsGenuine() to retry immediately. end; Else // TODO: Not genuine or not activated. Either way you should either // restrict the user from using your app or give the user a trial // of your app. end;
UseTrial() function starts and/or revalidates the trial. The
TrialDaysRemaining() function returns the number of days remaining in the trial. When
TrialDaysRemaining() returns 0 you should disable your apps features and require them to activate. See the example project.
Note: Always call
UseTrial() before calling
if isActivated then begin // your app is activated and genuine, see above end else begin // not genuine / not activated TurboActivate.UseTrial(); if TurboActivate.TrialDaysRemaining() = 0 then begin //TODO: disable the features of your app end; end;
Learn more about using trials & trial extensions to win over prospective customers.
We recommend you use the TurboActivate.exe for entering product keys and activating your product. In the example project we show how to launch TurboActivate.exe and then check if the user is activated after it closes.
If you want to build your own interface then just use the
CheckAndSavePKey(string pkey) and