ActivePatch Developer's Guide - Applying Patch Files

The process of applying the patch file uses the contents of a previously created patch to modify the original version of a file to produce the modified version. Using the same example that created the patch file, we'll copy the house1.mdb database file to a file named house.mdb. This is a copy of the original version of the database, and will be modified in place by the Apply method.

' Apply a patch file, creating the updated version of
' a file from the original version

PatchFile1.FileName = "house.pat"
PatchFile1.Password = "secret"
PatchFile1.Options = apBackupFile Or apIgnoreFileTime

On Error Goto CreateFailed
PatchFile1.Apply "house.mdb"
Exit Sub

CreateFailed:
MsgBox Err.Description
Exit Sub

The FileName property specifies the name of the patch file to apply against the original version of the file.

The Password property specifies the password that was used to secure the patch file when it was created.

The Options property specifies the options to be used when applying the patch. In this case, there are two options which are used. The first option that is specified, apBackupFile tells the function that you wish to create a backup copy of the original file when the patch is applied. This allows you to easily undo the changes made by the patch and revert to the previous version of the file. Backup copies of the file retain the same base file name, and the extension is replaced with a sequence number. In this example, the backup copy of the house.mdb file would be called house.000.

The second option specifies that the time that the file was last modified should be ignored when determining if the patch can be applied safely to the file. By default, the Apply method has a very stringent set of criteria to determine that the original version of the file has not been changed in any way; the apIgnoreFileTime option relaxes one of these criteria. Note that the function still performs checks on other attributes such as the size and checksum of the original file. The option to ignore any differences in the file timestamp is particularly useful when applying patches that are distributed over the Internet.

Because only one parameter was passed to the Apply method, this tells the control that you wish to overwrite the original version of the file with the updated version. In this example, before the method is called, the file house.mdb is identical to the original version of the database, house1.mdb. After the method successfully returns, house.mdb will be identical to house2.mdb, the updated version of the database. If an error occurs during the creation of the patch file, the error trap is triggered. In this case, a description of the error is displayed and the subroutine exits.