Any questions? Ask us: support@enigmaprotector.com

Plugin: Multiple instances & One registration dialog

Questions, downloads, issues related to plugins for Enigma Protector

Plugin: Multiple instances & One registration dialog

Postby Enigma » Mon Mar 12, 2018 1:38 pm

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.
Enigma
Site Admin
 
Posts: 2310
Joined: Wed Aug 20, 2008 2:24 pm

Re: Plugin: Multiple instances & One registration dialog

Postby syntax101 » Mon Apr 16, 2018 1:14 pm

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

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


Return to Plugins

Who is online

Users browsing this forum: No registered users and 3 guests