How to make the time report start at the program start (15 days), so that after 15 days the program deletes itself.

It is advisable to do with if else .

  • Also add the check "the current date should be more than the date of the previous launch" - vkhacker

2 answers 2

Like that

OnCreate; begin if DaysBetween(startdate,now)>15 then application.terminate; end; 

In the variable startdate you hold the date of the first launch, and where you decide to keep it, you want in the registry you want in the file, if you have enough knowledge, you can keep the resources in the ekzeshnik itself.

do not forget to add DateUtils in Uses

  • I, as a month, study an error in startdate. What to make variable? And how to do it.) - Vlad Andreev
  • First you check whether you have a variable, or is it the first run, if you start the first one, then you save the variable in a way that is convenient for you. If the variable is, then read it. type of variable TDateTime - vdk company

Will not work. Your program is probably installed on the client machine in a directory with rights to write root (administrator), that is, on Windows in %PROGRAMFILES% . And it is launched with the rights of the client. That is, there is no access to the directory for recording, you will not be able to remove yourself.

Of course, you can simply stop the program (by issuing an appropriate message to the user). Note, however, that your program is completely under the control of the user, so that a qualified user will find a way around the restriction.

PS: Do you necessarily if / else ? And case in any way?