Desmond
10-01-2003, 03:56 PM
<HTML> <HEAD> <TITLE>AutoPlay Media Studio 5.0 Knowledge Base</TITLE> </HEAD> <BODY> <h3>Setting my Application to Expire After a Certain Number of Executions</h3> <b>Document ID: IR10062</b> <hr> The information in this article applies to: <ul> <li>AutoPlay Media Studio 5.0 Standard Edition</li> <li>AutoPlay Media Studio 5.0 Professional Edition</li> </ul> <hr> <h3>SUMMARY</h3> <p>This article describes how to set your application to expire after a certain amount of executions.</p> <h3>DISCUSSION</h3> <p> 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.<br> <br> To accomplish this, insert the following code into the On Startup event of your project:<pre><code>times_allowed = 30;
<br />times_run = Application.LoadValue("My Application", "Has Been Run");
<br />times_run = String.ToNumber(times_run);
<br />times_remaining = (times_allowed - times_run)
<br />
<br />if times_run == "" then
<br /> Application.SaveValue("My Application", "Has Been Run", "1");
<br />else
<br /> Application.SaveValue("My Application", "Has Been Run", (times_run + 1));
<br />end
<br />
<br />if times_run >times_allowed then
<br /> Dialog.Message("Trial Period Over", "This software has expired");
<br /> Application.Exit();
<br />else
<br /> Dialog.Message("Trial Period", "You can run this program "..times_remaining.." more times.");
<br />end </code></pre> <h3>MORE INFORMATION</h3> <p>For more information please see the following topics in the AutoPlay Media Studio 5.0 help file:</p> <ul> <li><b>Program Reference | Actions | Application | Application.LoadValue</b></li> <li><b>Program Reference | Actions | Application | Application.SaveValue</b></li> <li><b>Program Reference | Actions | System | System.GetDate</b></li> </ul> <p>KEYWORDS: AutoPlay Media Studio 5.0, Expire, Trial, Version, Executions </p> <hr> <FONT SIZE=1> Last reviewed: October 1, 2003<br> Copyright © 2003 <A HREF="http://www.indigorose.com" target="blank">Indigo Rose Corporation</a>. All rights reserved.<br> </FONT> </BODY> </HTML>
<br />times_run = Application.LoadValue("My Application", "Has Been Run");
<br />times_run = String.ToNumber(times_run);
<br />times_remaining = (times_allowed - times_run)
<br />
<br />if times_run == "" then
<br /> Application.SaveValue("My Application", "Has Been Run", "1");
<br />else
<br /> Application.SaveValue("My Application", "Has Been Run", (times_run + 1));
<br />end
<br />
<br />if times_run >times_allowed then
<br /> Dialog.Message("Trial Period Over", "This software has expired");
<br /> Application.Exit();
<br />else
<br /> Dialog.Message("Trial Period", "You can run this program "..times_remaining.." more times.");
<br />end </code></pre> <h3>MORE INFORMATION</h3> <p>For more information please see the following topics in the AutoPlay Media Studio 5.0 help file:</p> <ul> <li><b>Program Reference | Actions | Application | Application.LoadValue</b></li> <li><b>Program Reference | Actions | Application | Application.SaveValue</b></li> <li><b>Program Reference | Actions | System | System.GetDate</b></li> </ul> <p>KEYWORDS: AutoPlay Media Studio 5.0, Expire, Trial, Version, Executions </p> <hr> <FONT SIZE=1> Last reviewed: October 1, 2003<br> Copyright © 2003 <A HREF="http://www.indigorose.com" target="blank">Indigo Rose Corporation</a>. All rights reserved.<br> </FONT> </BODY> </HTML>