UPDATE YOUR APPLICATION OVER THE INTERNET

Michael Cummings
MichaelCummings@BrickSoftware.com
January 13,2006

This is an auto-updating application.

If you want to see what it does, copy MyApplication.exe to an empty directory and run it.

Every time the application launches, it attempts to check for updates on the web site and folder that you specify.
If it cannot connect to the website, it just silently continues.

Since an exe cannot replace itself, the application is split into 2 pieces:
The launcher     = MyApplication.exe
The application  = MyApplicationLIB.exe

I want the user to never run the real application directly.
So I named the launcher with the name of the application = "MyApplication.exe" 
I named the real application as "MyApplicationLib.exe" to direct attention away from it.

I also pass a parameter to the real application to prevent the user from double clicking on it.

Any time you need to send updates, you just copy them onto the web site folder.
Any sub-folders that you create on the web site will be created on the users machine.


**********************************************************************************************
HoW IT WORKS
**********************************************************************************************
On the web site we create a folder to hold our program files.
In the example it is "http://www.brick.cx/lafox_update_your_app"

Any files we want the user to have are put into that web folder.

We also put manifest.php in that folder.
Manifest.php is a script that will generate a directory listing in plain text
containing the name of each file, its size, and date

The launcher calls the php script and compares it to a manifest.txt on the user's machine.
If there are new or changed files or folders we ask the user if he wants to update.

After the update is over, we launch the real application using the Windows api ShellExecute.


**********************************************************************************************
WHAT IF I NEED TO UPDATE THE DATABASE?
**********************************************************************************************
Before any files are downloaded, you can check the list of new or updated files.
You can check for any special files and take whatever action you need to.

In the interest of brevity the example just puts up a messagebox.
In real life, you have to check for exclusive use, or send a message to the on site administrator, 
or handle it however you usually handle such things.

See the FUNCTION CheckFiles() at the bottom of launcher.prg

