Link to home
Start Free TrialLog in
Avatar of pr2501
pr2501

asked on

I need to make simple time trial app.


So how can it be done.

Read registration date?
Read actual date?

If  actual date - registration date > 30 then .......  ?

And is posible to check if bios time was changed in last 30 days?
Avatar of jimyX
jimyX

Did you try the mxProtector demo "TimeTrail"?
I am sure it does that exactly.
Avatar of pr2501

ASKER

Which procedures from  mxProtector demo ?
Set the mxProtector properties:
Expiration = the expiration date
Options:
  poAutoInit=True
  poCheckSystemTime=True
Protection Types:
  stTimeTrail = True

And the events:
OnExpiration:
OnTimeTrail:
OnInvalidSystemTime:
Procedure TForm1.mxProtectorExpiration( Sender: TObject );
Begin
  showmessage('This licence has expired');
  // disable all the controls here
End;

Procedure TForm1.mxProtectorTimeTrial( Sender: TObject; DaysRemained: Integer );
Begin
  if DaysRemained < mxProtector.GetLicencedDayNumber then
    begin
      showmessage('still have '+ inttostr(DaysRemained) +' days');
      // enable all the controls
    end
  else
    begin
      showmessage('System will lock up, the time trail is over!');
      // disable all the controls
    end;
  ;
End;

Procedure TForm1.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;

Open in new window

Here is a sample application, just adjust the time "Expiration" and test it, also try to change the system time and test it again.

>   "And is possible to check if bios time was changed in last 30 days?"
No, it is not possible unless your program keeps tracking it. For instance when your application is launched the first time, it will capture the bios time and store in the the registry or DB and whenever your application is launched again then it matches between the stored time and the current time and hence you detect any differences. Other than that you can't detect if it has changed.

PS: this is the simplest that it can be. So it can be improved more. But for the basic idea this will do.
mxProtector.zip
ASKER CERTIFIED SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pr2501

ASKER

In factory office i have sytem download prohibition for  zip files so i could not use
jimyX code.

Hi Ewagnowa, what else must i set to make it work because now i have mesage :
This licence was expired: 0 day remaining.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pr2501

ASKER

JimyX. Your code is doing fine.
A hope Ewangow will clear  settings: Expiration  and MaxDayNumber
to make it work fine too.
I am satisfied as we proceed. I hope You agree.
I will be out this weekend from tomorrow.
Avatar of pr2501

ASKER

Hi Ewangowa

What is wrong with setings to get next result?
norun.JPG
run.JPG

I dont have my workstation with mxProtector right now, there is a method if I remember in mxProtector called Reset, which is supposed to reset all the values and restart the time trial.


You can change the MaxDayNumber to whatever value you want.
I added the reset button just for test, this will restart the trial
CheckTrial.dfm
CheckTrial.pas
Avatar of pr2501

ASKER

OK. Does it mean
that expiration parameter do not have any sense.
(i can write any value in it - it does not make any difference, and if i live it blank
, with new restart of project, data of 5/7/2011 8:32:23 AM is set automatically)

That expiration date does nothing it time trial, and it can not be changed at runtime either.
You can even set it to last year and the program will still functions.
The important property is the MaxDayNumber