ActivePatch Developer's Guide - Package Properties and Resources

When a patch package is created for a given collection of files, there may be a need to provide the updating application with additional information about the update. This information may be used simply to provide the end-user with details about the update, or it may be used for some application specific purpose.

ActivePatch supports two types of application-specific metadata. This metadata is stored in the package itself in a compressed form, not as an external file. The first type of metadata is called a property, which is a specific type of string data. Package properties include information such as the name of the company which produced the package, a contact e-mail address, product URL, version and build strings, as well as other types of related information. Properties are also used by ActivePatch when it needs to determine the default installation directory for a given package. Combinations of the company name, product name, product version and registry key names are used when searching for the directory that a given product has been installed under. Two functions are used with package property values, GetPackageProperty and SetPackageProperty.

GetPackageProperty

The GetPackageProperty function returns the value of a specified property. Properties are referenced by pre-defined numeric values and represented as constants. The function returns the length of the requested property, or a value of zero if the property doesn't exist in the package.

SetPackageProperty

The SetPackageProperty function sets or changes the value of a specified property. Properties are referenced by pre-defined numeric values and represented as constants. By passing a NULL pointer or an empty string as a property value, the property is removed from the package.

In addition to package properties, there is also a more generic type of metadata called a resource. Unlike properties, package resources are completely user defined and may contain any type of data, including binary data. Resources are associated with a numeric value that is assigned by an application, and has meaning only to the application that has stored it in the package. For example, a developer may wish to store a bitmap image in the package which is displayed when the package is applied. The bitmap is loaded into memory, a numeric ID of the developer's choice is associated with the image, and then the image is stored in the package using that ID. To extract the bitmap from the package, the developer simply uses that same ID and provides a buffer which will contain the image data. Valid resource IDs are in the range of 0000h through EFFFh. The two functions which are used to manage resource metadata are LoadPackageResource and StorePackageResource.

LoadPackageResource

The LoadPackageResource function searches for a resource with the specified ID, and returns a copy of the data in the buffer passed as an argument to the function. If no resource exists with the specified ID, an error is returned.

StorePackageResource

The StorePackageResource function stores a block of data as a resource in the patch package. If the resource ID provided references a resource that already exists, that resource is replaced. The resource ID and data is completely application specific, and is not used by ActivePatch during the process of applying the package.

It is important to remember that although the resource metadata is compressed in the package, it will increase the overall size of the resulting package file.