ActivePatch Developer's Guide - Applying Package Files

To apply a package on a target system, the ApplyPackage function is used as follows:

// Apply a package file, updating the files in the specified
// installation directory

LPCTSTR lpszPackageFile = _T("update.pkg");   // package file
LPCTSTR lpszUndoFile = _T("update.rev");      // package undo file
LPCTSTR lpszPassword = _T("secret");          // package password
LPCTSTR lpszInstallDir;
BOOL bResult;

// Specify the default installation directory
lpszInstallDir = "<ProgramFiles>\\MyProduct";

bResult = ApplyPackage(lpszPackageFile,    // package file name
                       0,                  // package options
                       0,                  // reserved
                       lpszPassword,       // package password
                       lpszInstallDir,     // install directory
                       lpszUndoFile,       // package undo file
                       NULL,               // callback function
                       0);                 // callback parameter

The first parameter is the name of the package file that was previously created using the CreatePackage function. The second parameter is the options that are to be used when applying the package. A value of zero means that the function is to use those options that were specified when the package was created. Note that if one or more options were specified, then the default options would be ignored, and those options would be used instead. As with applying individual patch files, the password parameter should specify the same password that was used to create the package.

The next parameter specifies the name of the installation directory where the files are installed. In the above example, the directory is specified as a subdirectory under "C:\Program Files". However, because this directory can be named differently on other systems, it is preferable to use the <ProgramFiles> macro which is replaced with the name of the directory where programs are installed by default. There are a number of similar macros which can be used, and are listed in Appendix A of the technical reference.

The next parameter is the name of an "undo" file, which can be used to reverse the application of a patch package by calling the UndoPackageApply function. If an undo file is not required, then this parameter may be NULL or point to an empty string.

The last two parameters are used to specify a function which is called during the package application process, and an optional parameter to pass to that callback function. Because we are not using a callback function, a NULL pointer is passed as the function address and a value of 0 is passed as the callback parameter.