Below is the UserMain script code. Custom code has been added to work with a licensing script TrackMySoftware. This works fine with version 1.7.
uses
Classes;
// UserMain
// This script contains special functions related to some of the events triggered by the application.
// You can then optionally add new commands.
// TrackMySoftware
// Blank script
// Add your own procedures and functions.
const
URL = “http://website.co”;
AuthKey = “xxxxxxxxxxxxxxxxxxxxx”;
ProdID = “00003”;
ProdVer = “1.1”;
LicFile = “”; //default location
function tms_GetStatus(URL, AuthKey, ProdID, ProdVer, LicKey, LicFile: PWideChar): BOOL; stdcall; external “tms.dll”;
function tms_Uninstall(URL, ProdID, LicKey: PWideChar): BOOL; stdcall; external “tms.dll”;
function tms_CloseApp(URL, ProdID, LicKey: PWideChar): BOOL; stdcall; external “tms.dll”;
function tms_SetInfo(URL, ProdID, Info1, Info2, Info3: PWideChar): BOOL; stdcall; external “tms.dll”;
function tms_GetInfo(URL, ProdID: PWideChar): BOOL; stdcall; external “tms.dll”;
function tms_SendFeedback(URL, ProdID, Name, Email, Feedback: PWideChar): BOOL; stdcall; external “tms.dll”;
function tms_GetProdVer(URL, ProdID: PWideChar): BOOL; stdcall; external “tms.dll”;
function tms_GetAPIVer(URL: PWideChar): BOOL; stdcall; external “tms.dll”;
function tms_GetDeviceID: PWideChar; stdcall; external “tms.dll”;
function tms_GetLastMsg: PWideChar; stdcall; external “tms.dll”;
function tms_Decrypt(Authkey, LicFile: PWideChar): BOOL; stdcall; external “tms.dll”;
//==========================================================================
function GetStatus(URL, AuthKey, ProdID, ProdVer, LicKey, LicFile: string): Boolean;
begin
Result := tms_GetStatus(URL, AuthKey, ProdID, ProdVer, LicKey, LicFile);
end;
function GetStoredLicenseKey: string;
begin
Result := GetGlobalVar(“LicKey”, “”);
end;
function IsUnregisteredOrExpired: Boolean;
var
LastStatus: string;
var
LastMsg: TStringList;
begin
Result := not tms_GetStatus(URL, AuthKey, ProdID, ProdVer,
GetStoredLicenseKey, LicFile);
LastMsg := TStringList.Create;
try
LastMsg.CommaText := tms_GetLastMsg;
SetGlobalVar(“LastStatus”, LastMsg[0], False);
finally
LastMsg.Free;
end;
end;
function GetLastStatus: string;
begin
Result := GetGlobalVar(“LastStatus”, “”);
end;
function OnBeforeNavigate(NewURL, TargetFrame: String): Boolean;
begin
// Before the application displays a page. Set Result to True to stop the operation.
Result := False;
end;
procedure OnPHPErrorMessage(ErrorMsg: String);
begin
// When an error is returned by the PHP runtime.
end;
procedure OnNavigateComplete(URL: String);
begin
// When a page has been displayed.
end;
function OnPubLoaded: Boolean;
var
// s: string;
DLLPath: String;
begin
// When the application is starting.
// Set Result to True if you want to exit immediately without any warning.
DLLPath := GetGlobalVar(“HEPublicationPath”, “”);
UnpackVirtualResource(“tms.dll”,DLLPath + “tms.dll”);
if IsUnregisteredOrExpired then
begin
S := InputBox(“Trial period expired, please enter registration key:”, “Unregistered”, “”);
if S = “” then
begin
// Start the browser and quit
// Result := True;
Result := False;
exit;
end;
SetGlobalVar("LicKey", S, True);
if IsUnregisteredOrExpired then
begin
MessageBox("Invalid registration key", "Error", 0);
// Result := True;
Result := False;
// GoToPage (“register-software.php”, “”)
Exit;
end;
end;
Result := False;
end;
procedure OnPubBeingClosed;
begin
// When the application is going to be closed.
end;
procedure OnDisplayWindow(WindowName: String);
begin
// When a window is going to be displayed (including main and secondary windows).
end;
procedure OnStartMainWindow;
var
i: Integer;
begin
if IsUnregisteredOrExpired then
begin
ShowMessage("GetStoredLicenseKey: " + GetStoredLicenseKey);
ShowMessage("GetLastStatus: " + GetLastStatus);
if GetLastStatus = “LicExpired” then
begin
OpenFile(“http://something.com”, “”, SW_SHOWNORMAL);
ExitPublication;
end;
else
GoToPage (“register-software.php”, “”)
end
else
begin
//license is valid, checking for custom status
if GetLastStatus = “CustomStatus” then
begin
ShowMessage(“Handle some custom status”)
end;
end;
end;
procedure OnCloseWindow(WindowName: String);
begin
// When a window is closed by the user.
end;
function OnTimer(TimerName: String): Boolean;
begin
// Occurs when a specified amount of time, determined by StartTimer HEScript function, has passed.
// Note: use StopTimer to disable the timer or set Result to True.
Result := False;
end;
function OnInvalidPasswordAtStartup: Boolean;
begin
// Occurs when an invalid global password is provided.
// Note: set to True if you want the application NOT to display an error message and exit.
Result := False;
end;
function OnExpiredPublication: Boolean;
begin
// Occurs when the global expiration date is reached.
// Note: set to True if you want the application NOT to display an error message and exit.
Result := False;
end;
procedure OnTrayIconClick;
begin
// The user clicks on the tray icon.
end;
procedure OnTrayIconDblClick;
begin
// The user double-cclicks on the tray icon.
end;
procedure OnPrintPage;
begin
// When a user wants to print the current page.
end;