How do I...?

Run my Application Only Once

To run your application only once (i.e. the first time the user inserts your CD-ROM, and no other time), place the following code in the On Startup event of your project:

--retrieve value from the registry. If the key does not exist, result = ""
result = Application.LoadValue("Application_Name", "First_Time");

--if there was no key, the program has never been run
if result == "" then --if there is no value set, the string will be empty
    Application.SaveValue("Application_Name", "First_Time", "yes");
    Dialog.Message("title", "this is the first time this program has run");
else
    Application.Exit();
end

Tip: Pro Edition users can use Window.Close(Application.GetWndHandle(), CLOSEWND_TERMINATE) in place of Application.Exit().  This will close the window before the window draws itself (i.e. the user will see nothing).


Applies to:

Standard Edition

Professional Edition