How do I...?

Expire my Application After Thirty Days

To make your application expire after thirty days, store the date the program was first run in the registry, and every consecutive time that the program is run, compare the registry to the expiry date (30 days after your program was first installed).

To accomplish this:

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

-- Initialize variables
days_left = 30;
date_installed = Application.LoadValue("My Application", "Date Installed");
time_limit = 30; --the length of the trial period, in days

-- Convert string value to number
date_installed = String.ToNumber(date_installed);


-- Was date_installed 0 (non-existent)?
if date_installed == 0 then
  -- Value was nonexistent, create it
    Application.SaveValue("My Application", "Date Installed", System.GetDate(DATE_FMT_JULIAN));
else
  -- Update days_left
    days_left = (date_installed + time_limit) - System.GetDate(DATE_FMT_JULIAN);
end

-- Are there days left?
if days_left < 1 then
  -- There are not any days left, alert user and exit.
    Dialog.Message("Trial Period Over", "This software has expired");
    Application.Exit();
else
  -- There are days left, alert user how many
    Dialog.Message("Trial Period", "You have "..days_left.." days left in your trial period.");
end

Сайт управляется системой uCoz