|

How do I... ?

AnswerList of Questions


Expire my Application After a Certain Date


To make your application expire after a certain date, set a variable in your program to the expiry date, and every time the program is run, check the current date against that value. If your program is expired, it will close.


To accomplish this:


image

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


--Input your expiration date here, format YYYYMMDD

--(no spaces, dashes, slashes, etc. just use numbers)

--Below is the date Dec 12, 2003 Expiration_Date = "20031212"


--Get the system date in ISO format

--Date = YYYY-MM-DD

Date = System.GetDate(DATE_FMT_ISO);


--Remove the dashes in the ISO format date

--to reflect the format of our expiry date

--Date == YYYYMMDD

Date = String.Replace(Date, "-", "", false);


--test to see if the application is expired if Date > Expiration_Date then

--The application has expired

Dialog.Message ("Application Expired!", "Your copy of this application has expired! This program will now exit.");

Application.Exit();

end


image

How do I... ?

AnswerList of Questions


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:


image

-- Set the number of times allowed times_allowed = 30;


-- Retrieve the number of times run and convert the value to a number

times_run = Application.LoadValue("My Application", "Has Been Run");

times_run = String.ToNumber(times_run);


-- Calculate the number of allowed run times remaining times_remaining = (times_allowed - times_run)


-- Check if this is the first time the application has been run

-- Save the new number of times run value if times_run == 0 then

Application.SaveValue("My Application", "Has Been Run", "1"); else

Application.SaveValue("My Application", "Has Been Run", (times_run + 1));

end


-- Check if the application has been run more times than allowed 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


image

How do I... ?

AnswerList of Questions


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:


image

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


image

-- 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


image

How do I... ?

AnswerList of Questions


Get System Folder Paths


AutoPlay Media Studio includes an action to get the paths to various folders on your computer. To accomplish this, use the action Shell.GetFolder.


As an example, we will get the path to the user's desktop, and store it in a variable path_to_desktop:


1. Insert the following code into an event in your program:


image

path_to_desktop = Shell.GetFolder(SHF_DESKTOP);


image

image

How do I... ?

AnswerList of Questions


Get the Registered User of the Computer


To detect the registered user of the system in AutoPlay Media Studio:


image

1. Insert the following script in the On Startup event of your project:


user = System.GetUserInfo();


Note: User is a table variable. To display this information on a page in your application, reference:

image

user.RegOwner - the registered owner of the computer user.RegOrganization - the registered organization


image

|