CPackage::Update

The CPackage::Update function updates an existing package with the specified files, either adding new files or replacing existing files in the package.

BOOL Update(
DWORD dwUpdateFlags, // update options
DWORD dwTargetPlatform, // target platforms
LPCTSTR lpszReferencePath, // old file specification
LPCTSTR lpszUpdatePath, // new file specification
LPCTSTR lpszInstallPath, // installation directory
LPCTSTR lpszExcludeMask // file exclude mask
);

Parameters

dwUpdateFlags
[in] Specifies the options which determine how updated files are added to the patch package.
 
The following values may be used:
Value Description
PACKAGE_UPDATE_RECURSIVE The reference and update directories should be recursively scanned for new, modified and deleted files. If this update option is not used, only those files in the specified directory will be included in the package.
PACKAGE_UPDATE_PARTIAL This is a partial update, therefore files missing from the new file directory should not be marked for removal from the target system.
PACKAGE_UPDATE_ALWAYS_REPLACE Always replace changed files instead of creating a patch. The file on the target system will always be overwritten, regardless of its previous version.
dwTargetPlatform
[in] Specifies the platforms that the files may be applied to.
 
This may be one of the following values:
 
Value Description
PACKAGE_FILE_PLATFORM_DEFAULT The files may be applied on all Windows platforms. This is the same as specifying a value of PACKAGE_FILE_PLATFORM_WINDOWS.
PACKAGE_FILE_PLATFORM_WIN95 The files may be applied to a system running Windows 95.
PACKAGE_FILE_PLATFORM_WIN98 The files may be applied to a system running Windows 98 or Windows 98 SE.
PACKAGE_FILE_PLATFORM_WINME The files may be applied to a system running Windows ME.
PACKAGE_FILE_PLATFORM_WINNT40 The files may be applied to a system running Windows NT 4.0.
PACKAGE_FILE_PLATFORM_WIN2000 The files may be applied to a system running Windows 2000.
PACKAGE_FILE_PLATFORM_WINXP The files may be applied to a system running Windows XP.
PACKAGE_FILE_PLATFORM_WIN2003 The files may be applied to a system running Windows Server 2003.
In addition to the above platform-specific values, there are predefined values which specify platform groups:
 
Value Description
PACKAGE_FILE_PLATFORM_WIN32 The files may be applied to any 32-bit version of the Windows operating system.
PACKAGE_FILE_PLATFORM_WIN9X The files may be applied to any system running Windows 95, Windows 98 or Windows ME. They will not be applied on a system running Windows NT, Windows 2000 or Windows XP.
PACKAGE_FILE_PLATFORM_WINNT The files may be applied to any system running Windows NT, Windows 2000 or Windows XP. They will not be applied on a system running Windows 95, Windows 98 or Windows ME.
PACKAGE_FILE_PLATFORM_WINDOWS The files may be applied to any system running any version of Microsoft Windows.
lpszPassword
[in] A pointer to a null-terminated string which specifies a password that is used to secure the package. A package created with a password cannot be opened or subsequently modified without providing the password.
 
lpszReferencePath
[in] A pointer to a null-terminated string which specifies the files or directories that contain the original version of the files to be updated. This may specify a directory, in which case all files in the directory are scanned, or it may be a file name. The name may include wildcards to match one or more files. If the PACKAGE_FLAG_RECURSIVE option is specified, all subdirectories under the specified directory will also be scanned. If this parameter is NULL, the files specified by the lpszUpdatePath parameter will be added to the package and created on the target system.
 
lpszUpdatePath
[in] A pointer to a null-terminated string which specifies the files or directories that contain the updated version of the files. This may specify a directory, in which case all files in the directory are scanned, or it may be a file name. The name may include wildcards to match one or more files. If the PACKAGE_FLAG_RECURSIVE option is specified, all subdirectories under the specified directory will also be scanned. If this parameter is NULL, the files specified by the lpszReferencePath parameter willl be removed from the target system.
 
lpszInstallPath
[in] A pointer to a null-terminated string which specifies the location on the target system where the files will be created, modified or deleted. This parameter may be NULL, in which case the files will be installed in the default installation directory on the target system.
 
lpszExcludeMask
[in] A pointer to a null-terminated string which specifies one or more file names (typically with wildcards) that are to be excluded from the package. Multiple files may be specified by separating them with a semi-colon.

Return Values

If the CPackage::Update function succeeds, it will return a non-zero value.

If the function fails, it will return a value of zero. To get extended error information, call GetLastError.

Remarks

If you wish to include multiple versions of a file, or files with the same names targeted for different operating systems, you must use the CPackage::SetOptions function to set the PACKAGE_OPTION_MULTIPLE_VERSIONS option before calling this function.

This function will fail if the package is opened for read-only access.

An application method will be associated with each file that is added to the package. The possible application methods are: Create, Replace, Modify, and Delete. An application method for a given file is determined by this function through comparison of the files referred to by the lpszReferencePath and lpszUpdatePath specifications.

Requirements

Windows NT/2000/XP: Requires Windows NT 4.0 SP3 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Include apatch.h.
Library: Use apatch32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP.

See Also

CPackage::Apply, CPackage::Create, CPackage::SetOptions