DLLs
DLLS
SmartLicMan(64).dll
In essence, the SmartLicMan(64).dll encapsulates the Datasnap interface, eliminating the need to embed Datasnap libraries into the project, as they are only available in Delphi Enterprise or higher versions.
ILicenseAccess
ValidLicense Function
This function likely deals with validating a user license on a server. Here's a breakdown of the parameters:
ASystemUser: Username for the server (likely for authentication).
ASystemPassword: Password for the server (likely for authentication).
AHost: The hostname or IP address of the server (e.g., "127.0.0.1", "localhost", or a URL).
APort: The port number used for communication with the server.
APathInfo: An identifier specific to the application (e.g., "ds_smartapp5").
AUserName: The username to be validated for the license.
ALicenseKey: The license key to be checked against the user.
AWorkplaceID: A unique hardware identifier for the machine.
AClientUser: The username of the client currently logged in.
AClientIP: The IP address of the client machine.
AAnswer: An object likely containing additional information about the validation process.
ASSL (Boolean): A boolean value indicating whether to use HTTPS (true) or HTTP (false) for communication.
AAnswer: ILicenseAnswer: an interface that is populated by the ValidLicense function - see below
AProxySettings: IProxySettings: Interface, for more information see below.
In simpler terms: This function is called to validate a user's license on a server. It takes various details about the user, license, and machine and checks them against the server's records. The AAnswer object likely provides the result of the validation and potentially additional information.
ILicenseAnwer
ILicenseAnswer is an interface that is populated by the ValidLicense function and becomes available with updated data after calling ValidLicense:
ILicenseAnswer = interface ['{E9868003-838B-4A1D-ACFC-E138D651B9BD}'] // getter, setter... // getter, setter... property DaysLeft: Integer read GetDaysLeft write SetDaysLeft; property &Message: PChar read GetMessage write SetMessage; property Product: PChar read GetProduct write SetProduct; property NextClientCheckDate: Integer read GetNextClientCheckDate write SetNextClientCheckDate; property SessionId: PChar read GetSessionId write SetSessionId; property MaximumExceeded: Boolean read GetMaximumExceeded write SetMaximumExceeded; property MaxCount: Integer read GetMaxCount write SetMaxCount; property LicenseModel: Integer read GetLicenseModel write SetLicenseModel; property LicenseIsEnding: Boolean read GetLicenseIsEnding write SetLicenseIsEnding; // real license end property ServerLicenseExpired: Boolean read GetServerLicenseExpired write SetServerLicenseExpired; procedure Clear; end;
Feel free to query all properties of this object and personalize your license validation accordingly.
Here is a more detailed explanation of the code:
The ILicenseAnswer interface is a Delphi interface that is used to store license information.
The Message property stores a message about the license status.
The DaysLeft property stores the number of days left on the license.
The Product property stores the name of the licensed product.
The NextClientCheckDate property stores the date when the license will next be checked.
The SessionId property stores the session ID for the license.
The MaximumExceeded property indicates whether the maximum number of licenses has been exceeded.
The MaxCount property stores the maximum number of licenses allowed.
The LicenseModel property stores the license model.
The LicenseIsEnding property indicates whether the license is nearing its end.
The ServerLicenseExpired property indicates whether the server license has expired.
The Clear procedure clears all of the properties of the class.
To use the ILicenseAnswer class, you would first call the ValidLicense function to populate the class with data. You can then access the properties of the class to get information about the license.
IProxySettings
The AProxySettings: IProxySettings parameter from ValidLicense is currently not used extensively. It can currently be simply ignored.
DisconnectClient Function
This function seems to be responsible for disconnecting a client from the server. Here's a breakdown of the parameters:
ASystemUser: Username for the server (likely for authentication).
ASystemPassword: Password for the server (likely for authentication).
AHost: The hostname or IP address of the server (e.g., "127.0.0.1", "localhost", or a URL).
APort: The port number used for communication with the server.
APathInfo: An identifier specific to the application (e.g., "ds_smartapp5").
ASSL (Boolean): A boolean value indicating whether to use HTTPS (true) or HTTP (false) for communication.
ASessionID: The user ID of the client to be disconnected.
In simpler terms: This function is used to terminate a client's session on the server. It takes authentication details for the server and the ID of the client to be disconnected.
The SmartClientReg(64).dll: Convenient Encapsulation of Client-Side Functions
The SmartClientReg(64).dll provides a convenient way to encapsulate client-side functionality for license management and offline operation. It handles the functionality of not having to go online every time, as indicated by the "latest online sync date" and "Client online check interval" fields.
To achieve this, the DLL stores data in the registry under a key that you can choose when using the DLL. The data is encrypted to ensure security.
Data Stored in the Registry:
ExpireDate
ExpireDateHash
LicenseIsEnding
LicenseIsEndingHash
Product
ProductHash
OfflineLicense
OfflineLicenseHash
The values that end with "Hash" are encrypted using a hardware ID in this case, so that any modification or distribution of the keys is "noticed". This can be controlled through functions from the DLL via the ILocalLicense interface.
Hints
The ExpireDate field is populated through two methods:
a) Either by the online interval, e.g., 14 days. b) Or by the "true" expiration date. In this case, LicenseIsEnding is true!
If LicenseIsEnding is false and ExpireDate is greater than Date, then the "real" license has not expired, but you should still notify the user (as a reason) that they need to go online to synchronize with the server.
Please note
You are not obliged to use the DLL. It offers convenient integration for expected functionality.
Delphi Examples
Several Delphi examples are provided to demonstrate the access and interaction of the system. You can of course use the code from these examples and adapt it to your own needs.
ILocalLicense Interface:
The ILocalLicense interface is structured as follows:
type TCryptEvent = function(Sender: TObject; ACryptString: PChar): PChar of object;ILocalLicense = interface ['{D39A0BD7-9F33-4842-9B78-42DFB4F04259}'] // Properties function GetSalt: PChar; procedure SetSalt(const Value: PChar); property Salt: PChar read GetSalt write SetSalt;
function GetUserName: PChar; procedure SetUserName(const Value: PChar); property UserName: PChar read GetUserName write SetUserName;
function GetKeyCode: PChar; procedure SetKeyCode(const Value: PChar); property KeyCode: PChar read GetKeyCode write SetKeyCode;
function GetRegistryPath: PChar; procedure SetRegistryPath(const Value: PChar); property RegistryPath: PChar read GetRegistryPath write SetRegistryPath;
function GetProduct: PChar; procedure SetProduct(const Value: PChar); property Product: PChar read GetProduct write SetProduct;
function GetExpireDate: TDate; procedure SetExpireDate(Value: TDate); property ExpireDate: TDate read GetExpireDate write SetExpireDate;
function GetLicenseIsEnding: Boolean; procedure SetLicenseIsEnding(Value: Boolean); property LicenseIsEnding: Boolean read GetLicenseIsEnding write SetLicenseIsEnding;
// Functions function InternetConnected: Boolean; function DateManipulated: Boolean; function NeedOnlineCheck: Boolean; function ProductManipulated: Boolean; function LicenseIsEndingManipulated: Boolean; function OfflineLicenseManipulated: Boolean; function Manipulated: Boolean;
// System function GetWorkplaceID: PChar; function Encrypt(AValue: PChar): PChar; function Decrypt(AValue: PChar): PChar; function GetIPAddress: PChar; function GetWUserName: PChar;
/// If you set the OnEncryption and OnDecryption events /// from the Delphi interface ILocalLicense and thus /// overwrite the original encryption algorithm from the DLL, /// you must also manually adjust the password in the generated /// settings file afterwards, since the SmartConfigurator /// naturally does not know your own algorithm.
function GetEncryption: TCryptEvent; procedure SetEncryption(const Value: TCryptEvent); property OnEncryption: TCryptEvent read GetEncryption write SetEncryption;
function GetDecryption: TCryptEvent; procedure SetDecryption(const Value: TCryptEvent); property OnDecryption: TCryptEvent read GetDecryption write SetDecryption; end;
Properties of the ILocalLicense Interface:
Salt:
A property of type PChar that represents an encryption parameter that you can use to uniquely encrypt your data.
UserName:
A property of type PChar that is not yet used.
RegistryPath:
A property of type PChar that specifies the registry path or key where the data sent by the server is encrypted in the registry.
Product:
A property of type PChar that can be a product name.
ExpireDate:
A property of type TDate that represents the expiration date for the client check.
LicenseIsEnding:
A property of type Boolean that indicates whether the license is ending.
The system has the "Expiry Date" (actual license expiration) and "Client online check interval" fields in the license manager. The "latest online sync date" field in the "Client online check interval" field returns the date for the specific client.
If the date from the "latest online sync date" field is after the "Expiry Date", the flag - in this case, the property LicenseIsEnding - is set to true, and you can react accordingly in the client.
The Delphi example "MultiExample.dpr" demonstrates the use and retrieval of the data.
Functions:
InternetConnected:
A function of type Boolean that checks whether an internet connection exists.
DateManipulated:
A function of type Boolean that checks whether the Date field has been manipulated.
NeedOnlineCheck:
A function of type Boolean that checks whether an online connection needs to be established.
ProductManipulated:
A function of type Boolean that checks whether the Product field has been manipulated.
LicenseIsEndingManipulated:
A function of type Boolean that checks whether the LicenseIsEnding field has been manipulated.
OfflineLicenseManipulated:
A function of type Boolean that checks whether the OfflineLicense field has been manipulated.
Manipulated:
A function of type Boolean that checks whether there has been a general attempt to manipulate the registry.
System Functions:
GetWorkplaceID:
A function of type PChar that returns a unique hardware ID.
Encrypt:
A function of type PChar that encrypts a value.
Decrypt:
A function of type PChar that decrypts a value.
GetIPAddress:
A function of type PChar that returns the client-side IP address.
GetWUserName:
A function of type PChar that returns the client-side username.
Optional Events:
OnEncryption:
An optional event of type TCryptEvent that can be set and overwritten with your own encryption.
OnDecryption:
An optional event of type TCryptEvent that can be set and overwritten with your own decryption.
Please note
If you set the OnEncryption and OnDecryption events from the Delphi interface ILocalLicense and thus overwrite the original encryption algorithm from the DLL, you must also manually adjust the password in the generated settings file afterwards, since the SmartConfigurator naturally does not know your own algorithm.
Registry
When you use the SmartClientReg(64).dll and its functions through the interface, the registry key looks as follows: