1 (edited by toutheveste 2020-02-07 05:40:13)

Topic: trial and activate key

Please help me example
script to run the program
The trial period is 30 days, then the program requests the registration code

I noticed that I found examples on this site, but when you pause or modify your computer's clock, the program continues to run
thank you

Re: trial and activate key

Hello  toutheveste

Can this help you ?

procedure Form1_OnShow (Sender: string; Action: string);
var
   reg: TRegistry;
   iDays: integer;
begin
     reg := TRegistry.Create;
     reg.Access := KEY_ALL_ACCESS;
     reg.RootKey := HKEY_CURRENT_USER;
     reg.OpenKey('software\MyVisualDatabaseTrial',true);
     if not reg.ValueExists('StartDate') then reg.WriteDate('StartDate', Now+30); // trial period is 30 days

     iDays := Trunc(reg.ReadDate('StartDate')) - Trunc(Now); // time left days

     reg.CloseKey;
     reg.Free;

     if iDays < 1 then
     begin
          if MessageDlg('Trial period is over.'+#13+' Do you want to visit a order page?', mtInformation, mbYes+mbNo, 0) = mrYes
              then OpenUrl('http://yourpage.com');

          Form1.Close;
          Exit;
     end;

     if MessageDlg('Demo version. Time left: ' + IntToStr(iDays) +' days.'+#13+'Do you want to visit a order page?', mtInformation, mbYes+mbNo, 0) = mrYes
         then OpenUrl('http://yourpage.com');

end;

begin
end.

Obviously, if you change your system date (for example if you advance it by two days), the parameter passed in StartDate will be false and the value returned by reg.WriteDate ('StartDate', Now + 30); will prevent this code from working.

In addition I do not see the interest for a user to constantly make this maneuver to avoid the message displayed by this code (and not to pay a license).


JB