How do I...?

Expire my Application After a Certain Number of Executions

To make your application expire after a certain number of executions, store a value in the registry the first time the program is run, and increment it every consecutive time the program is run. Then, every time the program is run, check the stored value.

To accomplish this:

  1. Insert the following code into the On Startup event of your project:

times_allowed = 30;
times_run = Application.LoadValue("My Application", "Has Been Run");
times_run = String.ToNumber(times_run);
times_remaining = (times_allowed - times_run)
if times_run == "" then
    Application.SaveValue("My Application", "Has Been Run", "1");
else
    Application.SaveValue("My Application", "Has Been Run", (times_run + 1));
end

if times_run > times_allowed then
    Dialog.Message("Trial Period Over", "This software has expired");
    Application.Exit();
else
    Dialog.Message("Trial Period", "You can run this program "..times_remaining.." more times.");
end


Applies to:

Standard Edition

Professional Edition