Example:
Expiring 30 days after building

Actions used:

Application - Exit

Control Structure - END IF

Control Structure - IF

Dialog - Message Box

System - Get Date Time

In this example, we'll show you how to make your AutoPlay application expire 30 days after it was built.

Note that this won't protect any files that are distributed with the application; it only prevents the user from running the application itself. For example, if you're distributing your application on a CD-ROM, making the application expire won't protect the contents of the CD. For that, you'll need to investigate other security technologies.

Here's what the action list looks like:

First, we use a "System - Get Date Time" action to get the current date (when the application is run) in Julian Date format, and store it in a variable called %JulianDate%.

(A Julian Date is an integer value representing the number of days since midnight on January 1, 4713 B.C. For example, the Julian Date for September 23, 2002 is 2452541, and the Julian Date for September 24, 2002 is 2452542.)

Then we use a "Control Structure - IF" action to test whether the difference between the current date (%JulianDate%) and the date when the AutoPlay application was built—which was automatically stored in the design-time constant #JULIANDATE# at build time—is greater than 30.

Subtracting the Julian Date at build time (#JULIANDATE#) from the Julian Date at run time (%JulianDate%) gives us the number of days that have elapsed since the application was built; if that number is greater than 30, then our application is more than 30 days old. Note that we used parentheses in the conditional expression so the subtraction happens first, and then the result of the subtraction is compared to 30.

If the result of this test is true, then our application is more than 30 days old, and we want it to expire. We should probably tell the user what's happening, so next we use a "Dialog - Message Box" action to explain that the application has expired, and give them a URL where they can get a newer version.

(We could make things even easier for the user by opening that URL automatically with a "File - Open" action, or even automatically downloading the newer version with a "Internet - Download Web File" action. But for this example, a simple message will do.)

Next, we use an "Application - Exit" action to exit immediately from the AutoPlay application.

Finally, we use an "Control Structure - END IF" action to end the IF block.

Here's a link to the finished example, as an AutoPlay Media Studio 4.0 actions XML file that you can import into an action list:

(Note: save this file to your hard drive and use a tool like WinZip to extract the XML file)