Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming
A better way to protect your Delphi projects
mxProtector component was designed for quick implementation of application protection functions. You can create time-trial and password protected applications. You can set the maximum number of execution, and it can work with registration keys as well.
 More of this Feature
• Protect your Delphi Software : Tips and Recommendations
 Join the Discussion
"Post your views, comments, questions and doubts to this article."
Discuss!
 Related Resources
• Protection Tips
• Decompiling Delphi
• Developing Shareware
 Mx Components
• mxProtector Home
• mxProtector download

This article is an extension to "Protect your Delphi Software" discussion, intended to point you to some general and more specific solutions to software protection. Today, we'll take a closer look at one Delphi component that has everything you need in one place.

   mxProtector
mxProtector is a non visual Delphi component, designed for quick implementation of application protection functions. You can create time-trial and password protected applications. You can set the maximum number of execution, and it can work with registration keys as well. The stored information- passwords, registration keys etc. - are coded.

The mxProtector is available from Max's component page, on the downloads page you can see that mxProtector is distibuted as freeware for Delphi version 5 and 6; mxProtector for Delphi 7 is distributed as shareware. Source code for all versions is available on purchase.

TmxProtector The component is distributed as a Delphi package, to install it in Delphi, open the mxProtector_dX.dpk (where X stands for 5, 6 and 7) project file, compile and install it. When complete, the TmxProtector will be available in Max Palette.

The mxProtector component comes with 8 demo projects, each coded to explain one of the protection types.

In this article we'll explore one of the demo projects, namely how mxProtector deals with day trial expirations - the possibility to disable program usage after X days or after some specific TDateTime value (date and time).

First, let's see how to use the mxProtector for a day trial protection, in general:

   mxProtector - how to use
mxprotector in Object Inspector 1. Drop the component on your form.

2. If you want to start the initialization manually switch the poAutoInit off in the Options, and do not forget to call the Init method in your code.

3. Choose protection type or types, and set the ProtectionTypes property accordingly.

4. If you have chosen day trial protection, fill up the MaxDayNumber property. It is the number of days while your software runs after first start. Please note that this property is read-only in run-time. Now you have to create the following events: OnExpiration (Will be called when the trial time expired), OnDayTrial (Will be called if more than 1 day remaining). It gives your information about how many days remaining from trial period). If you include the poCheckSystemTime in Options, component checks user's computer Bios date and time. If it was set back, the OnInvalidSystemTime event will be called. Warning: If the poWorkAfterExpiration is included in Options, then OnDayTrial will be called after expiration date. 5. With day trial protection the begin time will be the day of first application start on the client's computer.

Note, the above text, was copied from the readme.txt file placed in the mxProtector setup folder. The readme.txt file describes the steps needed to "set-up" the component for all other protection types.
 

   Day Trial DEMO
Under the mxProtector install directory, you'll find a demo folder hosting a day trial demo project.

mxprotector run time


The code behind
In this day trial demo project, the poInit in Options property is True. This method calls all checking in the beginning (form Load), but you can call procedure CheckDayTrial any time in your code manually. The OnDayTrial event handler looks like:

procedure Tfrm_MainWindow.mxProtectorDayTrial
  (Sender: TObject;DaysRemained: Integer );
Begin
 if DaysRemained = 1 Then
   lbl_Message.Caption := 'Only one licenced day left'
 Else
   lbl_Message.Caption := Format('This software licence will 
                          expire after %d days.', [DaysRemained] );

 btn_Reset.Enabled := FALSE;
 btn_Go.Enabled := TRUE;
 ProgressBar.Max := mxProtector.MaxDayNumber;
 ProgressBar.Position := DaysRemained;
End;

The OnDayTrial event is a perfect place to put some warning message displaying how many days are left for the user to test your software.

The OnExpiration event gets fired when the license has been expired. Use it to disable some (or all) features of your software.

procedure Tfrm_MainWindow.mxProtectorExpiration( Sender: TObject );
begin
 lbl_Remaining.Caption := '0 days remained';
 lbl_Message.Caption := 'This license has expired';
 btn_Go.Enabled := FALSE;
end;

Remember that if you include the poCheckSystemTime in Options, mxProtector checks user's computer Bios date and time. If it was set back, the OnInvalidSystemTime event will be called.

procedure Tfrm_MainWindow.mxProtectorInvalidSystemTime
(Sender:TObject);
begin
 MessageDlg('Your system time is invalid.' + #13 + #10 + 
            'Please set the correct date and time to continue.',
            mtError, [mbOK], 0);
end;

   mxProtector - a relief in Delphi protection
To be honest I'm quite amazed with this component! It's *free*, no free sources though. Sources for Delphi 7 version are available for 40 EUR.

If you know of any other Delphi protection component that can be marked as "all-in-one", please do send me an email.

That's it on software protection for the moment - I hope unregistered users won't bother you any more!

   Want a better licensing policy for your Delphi applications?
mxLicence Manager tool supports easy implementation of licence management under Borland Delphi 4,5,6,7. Users of the application can share their licences on standalone PC or over the network. License administrators can control who uses the licensed application.

The client application communicates with the licence server through TCP/IP protocol. The client application and the license server can run on separate computers on your network...

Explore Delphi Programming

About.com Special Features

Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.