// Retrieve CPU ID (simplified - requires actual CPUID call) WbemObjectSet := WbemServices.ExecQuery('SELECT ProcessorId FROM Win32_Processor'); if WbemObjectSet.Count > 0 then CpuId := WbemObjectSet.ItemIndex(0).ProcessorId;
Remember: No activation system is 100% unbreakable. Your goal is to raise the bar high enough that casual piracy is impractical. For Delphi 2016 developers, the tools are all in your hands— System.Hash , WMI, and strong file I/O give you everything you need. File Activation Delphi 2016
// Retrieve Volume Serial of C: WbemObjectSet := WbemServices.ExecQuery('SELECT VolumeSerialNumber FROM Win32_LogicalDisk WHERE DeviceID="C:"'); if WbemObjectSet.Count > 0 then VolumeId := WbemObjectSet.ItemIndex(0).VolumeSerialNumber; // Combine and hash HashBytes := THashSHA2.GetHashBytes(MacAddress + CpuId + VolumeId); Result := TNetEncoding.Base64.EncodeBytesToString(HashBytes); finally CoUninitialize; end; end; Define a record that holds license data. This will be serialized, signed, and saved to disk. // Retrieve CPU ID (simplified - requires actual
// Node-locking: Compare stored HardwareID with current machine CurrentHardwareID := GetHardwareID; if CompareMem(@License.HardwareIDHash[0], @CurrentHardwareID[1], Length(CurrentHardwareID)) then begin // Check expiration if License.ExpirationDate > Now then Result := True; end; finally LicenseStream.Free; end; end; In your main project file ( .dpr ) or in the OnCreate event of your main form: // Retrieve Volume Serial of C: WbemObjectSet :=
procedure SignLicenseFile(const LicenseFile: string; const PrivateKey: TArray<Byte>); var LicenseStream: TFileStream; License: TLicenseData; DataToSign: TBytes; Signature: TBytes; begin // Populate License fields (UserName, ProductCode, ExpirationDate, HardwareIDHash, FeatureMask) // ... // Create binary representation of data EXCLUDING the signature field DataToSign := BytesOf(License.UserName) + BytesOf(License.ProductCode) + BytesOf(License.ExpirationDate) + BytesOf(License.FeatureMask) + BytesOf(License.HardwareIDHash);
type TLicenseData = packed record Magic: Integer; // Constant identifier, e.g., $4C494345 ('LICE') Version: Byte; // License format version UserName: array[0..99] of Char; ProductCode: TGUID; ExpirationDate: TDateTime; FeatureMask: Int64; HardwareIDHash: array[0..63] of Char; // Base64 of machine hash Signature: array[0..255] of Byte; // RSA signature (2048-bit) end; Your activation server (or a simple Delphi tool you keep in-house) signs the file. You will need a private key (e.g., from OpenSSL). For brevity, assume you have a SignData function that uses RSA-SHA256.