Skip to content

Software License Dongle for Delphi

Delphi applications are disproportionately likely to be exactly the kind of software worth protecting: long-lived engineering, measurement, medical and industrial tools, often with a decade or more of accumulated domain knowledge inside them.

Lazarus OPM version badge

Lazarus installs the keynub_licdongle package through the Online Package Manager; it comes with a demo project that runs without a dongle. Delphi adds LicDongle.pas from the SDK repository to the project.

They are also disproportionately likely to be stuck on a dongle whose vendor has moved on, discontinued the part, or dropped support for the parallel or USB-A device the software was built around. KeyNub binds through a plain Pascal unit over the same stable C ABI every other language uses, so migrating is a matter of swapping the calls, not restructuring the application.

Using It

Add LicDongle.pas to your project and deploy the shared library alongside your executable.

uses LicDongle;

var
  Ctx: TLicdCtx;
  Dev: TLicdDevice;
  Genuine: TLicdGenuineResult;
begin
  if licd_init(Ctx) <> LICD_OK then Halt(1);
  try
    if licd_open(Ctx, nil, Dev) <> LICD_OK then Exit;   // first dongle found
    try
      if licd_verify_genuine(Dev, Genuine) <> LICD_OK then Exit;
      if licd_session_open(Dev) = LICD_OK then
      begin
        // records and app-crypto go through Dev while the session is open
        licd_session_close(Dev);
      end;
    finally
      licd_close(Dev);
    end;
  finally
    licd_free(Ctx);
  end;
end;Code language: Delphi (delphi)

Bitness

Deploy the shared library matching your build target — a 32-bit Delphi application needs the 32-bit library, and both are supplied. Unlike the VB6 route, there is no calling-convention trap here: Delphi declares cdecl correctly, which is what the C ABI uses.

Do Not Gate on a Boolean

// Weak: one patched conditional jump.
if Genuine.genuine <> 0 then EnableFeature;

// Strong: data the program cannot compute for itself.
if licd_app_decrypt(Dev, @Blob[0], Length(Blob), OutBuf, OutLen) = LICD_OK then
  LoadCoefficients(OutBuf, OutLen);Code language: Delphi (delphi)

Native code is harder to patch than a .NET assembly, but not hard enough to rely on. Put the dongle on the critical path and the question stops being how well your check is hidden.

Shipping the Native Library with a Delphi or Free Pascal Application

The binding is one unit, LicDongle.pas, that compiles under Delphi and under Free Pascal in {$MODE DELPHI}; Lazarus users install the keynub_licdongle.lpk package from the Online Package Manager. The unit loads keynub_licdongle.dll at run time, so deployment is the DLL next to the executable or on PATH, in the bitness of your executable: a 32-bit VCL application takes the x86 build, a 64-bit one the x64 build.

On Linux the same unit loads libkeynub_licdongle.so, on macOS the .dylib, so a cross-platform FMX or Lazarus project needs no code change, only the matching library in the bundle. On Linux, install the udev rule from NATIVES.md once, so that ordinary users may open the device.

Questions Delphi Developers Ask

Which Delphi and Free Pascal Versions Does the Binding Support?

Current Delphi releases and Free Pascal 3 in Delphi mode, 32-bit and 64-bit, on Windows, Linux and macOS; Lazarus installs it from the Online Package Manager.

Why Does the DLL Report File Not Found Although It Is There?

Almost always bitness: a 32-bit executable cannot load the 64-bit DLL and Windows reports it as missing. Take the library from natives/win-x86/ for 32-bit builds and win-x64/ for 64-bit ones.

Does a Delphi Application Need Administrator Rights to Talk to the Dongle?

No, and no driver either: the dongle is a USB HID device that the operating systems handle with their built-in class drivers. On Linux, install the shipped udev rule once so that ordinary users may open it; without the rule the SDK reports access denied and names the cause in its error detail.

Does a Delphi License Check Need an Internet Connection?

No. Verification is a local exchange between your program and the dongle over USB: the SDK checks the dongle’s certificate chain to KeyNub’s root and runs a live challenge-response. There is no activation server and no account, so the check works on air-gapped machines.

Who Can Read the License Records on a Dongle?

Anyone holding the dongle: a program opens a session and reads records, and can decrypt data sealed for that dongle. Writing records, erasing them and incrementing counters need your write key. What the dongle guarantees is that none of it is available without the dongle present.

Can a License Written from Delphi Be Read by a Program in Another Language?

Yes. Every binding drives the same core library and the same dongle, and records and sealed data are language-neutral bytes. Your issuing tool can be written in one language and your product in another.

Code

Runnable sample: delphi/VerifyAndRead.dpr. Binding source: bindings/delphi. Lazarus package: keynub_licdongle.lpk. Both are Apache-2.0, in the public SDK repository; the prebuilt native libraries are in the repository’s natives/ folder, one per platform.

All supported languages · All industries · Buy a KeyNub · Ask us something