Page 1 of 1

Enhanced Key Expiration Reminder plugin

Posted: Thu Dec 29, 2022 1:14 pm
by Enigma
This plugin extends functionality of Registration Features - Key Expiration Reminder function.

What it does - before specified number of days of key expiration it shows a reminder and allows to open a registation dialog to enter new license key (or just skip it).

The reminder message looks as following:
ke1.png
To apply the plugin, the following needs to be done:
1. Copy keyexpiration.dll plugin (attached to the post) to "Plugins" folder of Enigma, copy or restart Enigma Protector
2. Enable Registration Features - Registration Dialog, with the following parameters
ke2.png
3. Disable Registration Features - Key Expiration Reminder
4. Miscellaneous - Plugins, enable keyexpiration.dll plugin
5. Protection Features - Protected Strings we need to enter three protected strings:
- first for message text, it has to have ID = 100 (in Options should set to WideString, this is important for unicode support)
ke3.png
- second for message title, it has to have ID = 200 (in Options should set to WideString)
ke4.png
- third indicates the number of days before expiration the message starts to appear, ID = 300 (in Options should set to Binary), just one byte of data
ke5.png
6. Protect the file. Key may have expiration by days or by date.

Re: Enhanced Key Expiration Reminder plugin

Posted: Thu Dec 29, 2022 1:15 pm
by Enigma
Source code:

Code: Select all

procedure Enigma_Plugin_OnInit;
var
  itemp : integer;
  dayslimit : byte;
  _year, _month, _day : cardinal;
  expitationdate : TDateTime;
  daystoexpiration : integer;
begin
  // This function is calling when the protected file is being initialized
  // when main program is not initialized yet

  // Check if key exists
  if EP_RegLoadAndCheckKey then
  begin

  // Check if key has expiration by date limitation
    daystoexpiration := -1;
    if EP_RegKeyExpirationDate(_year, _month, _day) then
    begin
      expitationdate := EncodeDate(_year, _month, _day);
      if expitationdate > Now then
      begin
        daystoexpiration := DaysBetween(Now, expitationdate);
      end;
    end;

    // Check if key has limitation by days
    if EP_RegKeyDaysTotal > 0 then
    begin
      daystoexpiration := EP_RegKeyDaysLeft;
    end;

    // If limitation by days is found, move forward
    if daystoexpiration <> -1 then
    begin
      // Extract from protected string the number of days to show the expiration reminder 
      EP_ProtectedStringByID(300, @dayslimit, 1);
      if daystoexpiration <= dayslimit then
      begin
        // Show expiration reminder, the message text is taken from protected strings
        if MessageBoxW(0, PWideChar(EP_ProtectedStringAsWideStringById(100)), PWideChar(EP_ProtectedStringAsWideStringById(200)), MB_ICONINFORMATION + MB_YESNO) = IDYES then
        begin
          // If Yes button is clicked, show a registration dialog
          EP_RegShowDialog;
        end;
      end;
    end;

  end; 
end;
Delphi sources and keyexpiration.dll are in attached archive.