
TurboPack OnGuard is a copy-protection system for VCL and FMX applications built using Delphi and C++ Builder.
In this article, I illustrate using TurboPack OnGuard and an integration with back-end Digital-River’s MyCommerce.
Digital River MyCommece platform is a sales ordering platform for customers to order software.
Table of Contents
Getting Started
In the below video you can see it takes less than a minute to install OnGuard.
Step 1. Select Tools > GetIt Package Manager, as seen below.

When the GetIt Package Manager Window appears (shown below).
1. type in “onguard”.
2. Click on the Install Button.

After installation, go to the Component Palette. Scroll to the bottom, you should see OnGuard, with all the registered components.
1. OnGuard VCL components
My First Licensed App
A sample copy-protected app takes around ~ 5 minutes to make.
Using TurboPower OnGuard, you first create a Key. You can right-click on an OnGuard component and click the “Generate Key” menu.

This will bring-up a Key Maintenance Dialog Box.
1. If you have not created a key. click the Button with Folder picture, to save the OnGuard key to disk.
2. If this is your first time, click the “Add…” button to generate a key.
3. Optional – copy Key to Clipboard.

If you selected [2] from the previous Dialog box, you will go to this small dialog box. Click on the Key Button to generate a key.

Errors Occurred during Development

You need to add code to the Component Event OnGetKey:
1 2 3 4 5 |
procedure TForm1.OgRegistrationCode1GetKey(Sender: TObject; var Key: TKey); const CKey: TKey = ($E5, $8F, $84, $D6, $92, $C9, $A4, $D8, $1A, $FA, $6F, $8D, $AB, $FC, $DF, $B4); begin Key := CKey; end; |
Then, add code to Event GetCode:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
procedure TForm1.OgRegistrationCode1GetCode(Sender: TObject; var Code: TCode); var Reg: TRegistry; S: string; begin Reg := TRegistry.Create(KEY_READ or KEY_WRITE); Reg.RootKey := HKEY_CURRENT_USER; Reg.OpenKey('SoftwareYourAppReg', true); try S := ''; if Reg.ValueExists('RegistrationCode') then S := Reg.ReadString('RegistrationCode'); {convert to proper form} HexToBuffer(S, Code, SizeOf(Code)); {set code label caption} CodeLbl.Caption := S; finally Reg.Free; end; end; |
Integration with Digital River Back-End
After your first sales, you find, you need to manually issue keys for your customer. If you have many orders, this becomes time-consuming affair. Wouldn’t you wish this could be automatic?
Digital River’s Admin Panel allows Delphi Console-Based VCL App to generate keys to be uploaded!In the below, a Key Issuance console app – digitalriver.keyissuance.yourapp.dpr does the job:
You need to replace PROD constant with the Product SKU ID from Digital River’s Admin Panel.
The CKey is same as embedded in your app.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
const // Product ID. Obtain from Digital River Admin Panel PROD = 100000001; // This key must be same as in App. CKey: TKey = ($E5, $8F, $84, $D6, $92, $C9, $A4, $D8, $1A, $FA, $6F, $8D, $AB, $FC, $DF, $B4); procedure GenerateKey(productId: integer; REG_NAME, EMAIL: string; p2, p3: string); begin var UserKey, CCKey: string; var ts1, ts2: TStringList; var Work: TCode; var OgMakeCodes1 := TOgMakeCodes.Create(nil); var dtNow := EncodeDate(2021, 12, 31); OgMakeCodes1.SetKey(CKey); InitRegCode(CKey, string(REG_NAME), dtNow, Work); CCKey := BufferToHex(Work, SizeOf(Work)); UserKey := 'Username: ' + UTF8Encode(REG_NAME) + #13#10 + 'Key: ' + CCKey; ts1 := TStringList.Create; try ts1.Add(UserKey); ts1.SaveToFile(p2); ts1.Free; except exitcode := ERC_FILE_IO; end; // ts2 := TStringList.Create; try ts2.Add(CCKey); ts2.SaveToFile(p3); ts2.Free; except exitcode := ERC_FILE_IO; end; OgMakeCodes1.free; exitcode := ERC_SUCCESS; end; |
There is a small test-case included in the source-code –
1 2 3 |
".digitalriver.keyissuance.yourapp.exe" "input.300775082.txt" "output.300775082user.txt" "output.300775082serial.txt" ".digitalriver.keyissuance.yourapp.exe" "input.300775083.txt" "output.300775083user.txt" "output.300775083serial.txt" pause |
After compiling the Key Issuance Delphi console application, upload it to Digital River’s Administration Panel.
The below shows example invoice (* certain information redacted as it is test invoice)


Entering Data from into the Demonstration App, the app is licensed –

OnGuard also works with Chinese, Korean, Thai and Arabic Names –

The source-code for this demonstration project is at https://github.com/PolywickStudio/OnGuardRecipe.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition