Plugin: Multiple instances & One registration dialog

Questions, downloads, issues related to plugins for Enigma Protector
Post Reply
Enigma
Site Admin
Posts: 2938
Joined: Wed Aug 20, 2008 2:24 pm

Plugin: Multiple instances & One registration dialog

Post by Enigma »

Next example of flexibility of our Enigma Protector with the plugins system!

We recently got a request from user to fit the following licensing scheme: there are multiple instances of protected application are being running, but only one copy should show a registration dialog, others should wait that.

If we try to apply the standard registration dialog feature to this complex scheme, we find that each running copy will show a registration dialog. This is what client would like to avoid.

We decided to develop a small plugin that will create an event object and while the first running copy shows the registration dialog, others will wait until it completes.

Sources of the project for Delphi and Lazarus are in attachment. Binary is also included.

The magic happes there:

Code: Select all

procedure Enigma_Plugin_OnInit;
var
  errorcode : dword;
  hndl : THandle;
begin
  // This function is calling when the protected file is being initialized
  // when main program is not initialized yet
  if EP_RegLoadAndCheckKey then
    Exit;

  hndl := CreateEvent(nil, true, false, 'ihiyGUgKUgukiU78yoihilh7ilgUgkuhGKJgI');
  if hndl <> 0 then
  begin
    errorcode := GetLastError;
    if errorcode = ERROR_ALREADY_EXISTS then
    begin
      WaitForSingleObject(hndl, INFINITE);
    end else
    begin
      EP_RegShowDialog;
      SetEvent(hndl);
    end;
    CloseHandle(hndl);
  end;
  if not EP_RegLoadAndCheckKey then
  begin
    ExitProcess(1);
  end;
end;
- first we check if application is already registered with EP_RegLoadAndCheckKey. If it is - continue execution
- then we create an event object
- if the event object is new one, we show a registration dialog
- if event object already exists, we run the wait routine WaitForSingleObjectthat, it waits the event to be signalled
- once first isntance finished with the registration dialog (user entered the license info or just closed it) it signals SetEvent to other processes to continue
- finally, everyone checks again if application is registered and calls ExitProcess on fail.
You do not have the required permissions to view the files attached to this post.
syntax101
Posts: 6
Joined: Thu Feb 15, 2018 12:39 am

Re: Plugin: Multiple instances & One registration dialog

Post by syntax101 »

This plugin is not working as it should, please refer to email for clarification about this plugins..

Thanks
syntax101
Posts: 6
Joined: Thu Feb 15, 2018 12:39 am

Re: Plugin: Multiple instances & One registration dialog

Post by syntax101 »

Any update for this plugin sir??
Post Reply