TRegistration Component - v1.02
( This file is best viewed full-screen)
--------------------------------------------------------------------------------

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
IMPORTANT - IF YOU DOWNLOADED THE 1.0 VERSION, PLEASE REPLACE IT WITH THIS VERSION.
THE 1.0 VERSION HAD A MEMORY LEAK!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

This component will allow you to make any program that you distribute a shareware program for an author-specified number of days.  In it's barest form it is ONE line of code in your program.
--------------------------------------------------------------------------------
  Copyright 1999 - Joseph L. Donth - All Rights Reserved.
  E-mail: jdonth@gte.net
  August 3, 1999
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Version 1.02
September 2, 1999
Changed version 1.01 to version 1.02
Added a fix to the Status method to correctly compute the license number on
NT systems.  Thanks to Tim Sommers (tim@ibsoft-us.com) for the fix.
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Version 1.01
August 3, 1999
Changed version 1.00 to version 1.01
Fixed a memory leak!
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

This software is freeware - after all the help and code I've received over the years, it's time to give a little something back.

mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Installing the Registration unit:
--------------------------------------------------------------------------------
You can install this unit on your Delphi component toolbar and just drop a copy of the component on to your Delphi program (it will install under the DONTH tab [ you can change that in the source code (registration.pas) ]).

In Delphi 4 just "Install Component" from the "Component" tab.

Or you can just include it with your program.  If you just include it, make sure that you create an instance of it in your OnCreate event handler "reg := TRegistration.create;" and make sure you destroy it on your OnDestroy event handler "reg.free;".


mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Using the TRegistration unit
--------------------------------------------------------------------------------
The TRegistration object has five properties, two methods and no events.
--------------------------------------------------------------------------------
Properties:
LICENSE [string] will return a system-generated license number for the computer that the software is running on.  LICENSE is NOT valid until after AFTER a call to the STATUS method.  Calling it before will return a null string.

NUMBER [string] will return the registration number for the given LICENSE value. Using this value in the VERIFY function will turn a shareware program into a registered one. Valid AFTER a call to STATUS.

DAYS [integer] will return the number of days left in the shareware period. Writing to this property before calling STATUS (with the NEW flag set TRUE) will set the number of days you will allow the program to operate without registering.  If you want allow an unlimited number of days in the shareware period, write a ZERO into this property. The default for this property is 30 days.

EXPIRED [Boolean] will return a TRUE if the program has expired or a FALSE if not.

REGISTERED [Boolean] will return a TRUE if the program is registered or a FALSE if not.

Note:
 A program can be in one of three states:
  Registered [REGISTERED = TRUE, EXPIRED = FALSE]
  Unregistered [REGISTERED = FALSE, EXPIRED = FALSE]
  Expired [REGISTERED = FALSE, EXPIRED = TRUE]

--------------------------------------------------------------------------------
Methods:
 Boolean := Reg.Status(PID:TGUID, Days:Integer, New:Boolean);
 Boolean := Reg.Verify(PID:TGUID, RGID:string);

--------------------------------------------------------------------------------
Reg.Status(PID, Days, New)

PID [TGUID] contains a unique Program ID.  Create one in your main unit before
calling Execute. See the demo program for an example.

DAYS [Integer] is the number of days the program will run without registration. This field is only used the FIRST time the STATUS method is called OR when the NEW flag is set to TRUE.

NEW [boolean].  If it set to TRUE, the program will be RESET and start the Shareware period over as specified by the DAYS and TIMES parameters. Normally, NEW would be set to FALSE.

Note if this is the first time the program is run it will properly create the security data even with NEW set to FALSE. You do not have to worry about toggling this field so unless you are changing a program's shareware option, this flag can remain FALSE.

--------------------------------------------------------------------------------
Reg.Verify(PID, RGID)

PID [TGUID] contains a unique Program ID.  Create one in your main unit before
calling Execute.

RGID [string] is the registration number that turns the program from a shareware
program to a registered one.

mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Some examples of use: [ The demo program shows all the pieces in one place ]
--------------------------------------------------------------------------------
1) You are including the registration code in a shareware program that you are writing.  You want the program to run for a maximum of 30 days as shareware.

Add the following code in your OnActivate event:

  if reg.status(ProgramID, 30, FALSE) = TRUE then begin // Expired
    ... do something about being expired...
  end; 

That's it!

--------------------------------------------------------------------------------
2) Same 30 day deal but you want to report more detail....

  if Reg.Status(ProgramID, 30, FALSE) then begin
   ShowMessage('This Shareware version of the software has expired....');
   close;
  end else begin
   if Reg.registered = TRUE then begin
    ShowMessage('Thank you for registering your version of the software...');
   end else begin
    ShowMessage('The software will expire in ' + IntToStr(Reg.days) + ' days.');
   end;
  end;


--------------------------------------------------------------------------------
3) Now suppose you want to register the software and the registration number has been entered into a field called edtRegister.text:

  if reg.verify(ProgramID, edtRegister.text) then begin
   ShowMessage('Thank you for registering');
  end else begin
   ShowMessage('Invalid registration number entered...');
  end;

--------------------------------------------------------------------------------
4) Finally, someone has talked you into extending the shareware status another 15 days.  You have a routine in your program that you call when that has been asked for:

 reg.Status(ProgramId, 15, TRUE);

Note: the TRUE will start the Shareware clock over again.  This time with 15 days.

mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
I hope you enjoy it!
                        -- Joe
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
