|
The CreatePatchFile function creates a
patch file based on the differences between a reference file and a modified version of
that file.
| BOOL CreatePatchFile( |
|
LPCTSTR lpszPatchFile, |
|
// name of patch file |
|
DWORD dwPatchLevel, |
|
// patch level |
|
DWORD dwPatchOptions, |
|
// patch options |
|
DWORD
dwPatchExpires, |
|
// patch expiration |
|
DWORD dwReserved, |
|
// reserved |
|
LPCTSTR lpszPassword, |
|
// password |
|
LPCTSTR lpszOldFile, |
|
// name of old file |
|
LPCTSTR lpszNewFile, |
|
// name of new file |
|
LPPATCHSTATUSPROC lpfnCallback, |
|
// pointer to callback function |
|
LPARAM lParam |
|
// callback function parameter |
| ); |
Parameters
- lpszPatchFile
- [in] A pointer to a null-terminated string which specifies
the name of the patch file that is to be created. If a file with the same name exists, the
file will be overwritten.
-
- dwPatchLevel
- [in] A value between 1 and 9 which determines the speed and
amount of memory allocated to create the patch. As a general rule, the higher the patch
level, the smaller the resulting patch file will be, at the expense of speed and the
amount of memory required. A value of 0 specifies a default patch level which is
appropriate for most files.
The following constants are defined:
-
| Value |
Description |
| PATCH_LEVEL_DEFAULT |
A default compression level should be
selected which is appropriate for most files. It is recommended that this value be used. |
| PATCH_LEVEL_MINIMUM |
Maximize the speed of the patch creation
process; this results in faster patch generation using less memory at the expense of
creating larger patch files. |
| PATCH_LEVEL_MAXIMUM |
Maximize the compression ratio of the patch
file; this results in smaller patch files at the expense of slower patch file generation
and increased memory utilization. |
dwPatchOptions
- [in] Specifies a default set of options which are used
during the patch apply process.
-
- One or more of the following values may be used:
-
| Value |
Description |
| PATCH_OPTION_FIND_FILE |
If the reference file cannot be found on the
target system, attempt to locate it using the standard Windows pathing rules. The current
directory, system directory and the directories in the PATH environment variable are
searched in that order. |
| PATCH_OPTION_BACKUP_FILE |
Create a backup of the file on the target
system before applying the patch. If this flag is not specified, the file is modified
in-place without any backup file being created. |
| PATCH_OPTION_COMPARE_FILETIME |
Compare the time that the target file was
last modified against that of the reference file. If the target file has a later
modification time than the reference file at the time the patch was created, the patch
application will fail with the error AP_ERROR_NEWER_FILETIME. In effect this ensures that
the updated file must always have a later modification time than the reference file. |
| PATCH_OPTION_COMPARE_VERSION |
Compare the version of the target file
against that of the reference file. If the target file has a later version than the
reference file at the time the patch was created, the patch application will fail with the
error AP_ERROR_NEWER_VERSION. In effect this ensures that the updated file must always be
a later version than the reference file. |
| PATCH_OPTION_IGNORE_FILETIME |
Ignore any differences between the file
modification times of the file on the target system and those of the reference file at the
time that the patch was created. |
| PATCH_OPTION_IGNORE_VERSION |
Ignore any differences between the version of
the file on the target system and the version of the reference file at the time that the
patch was created. |
| PATCH_OPTION_IGNORE_ATTRIBUTES |
Ignore the updated file attributes when the
patch is applied on the target system and use default attributes instead. |
| PATCH_OPTION_IGNORE_READONLY |
Ignore the read-only file attribute when
applying the patch. If the updated file has this attribute set, it will be cleared. |
| PATCH_OPTION_IGNORE_SIGNATURE |
Ignore any digital signature that may be
present. If the updated file has been digitally signed using AuthentiCode,
the signature will be authenticated at the time that the patch is applied. If this flag is
specified, no attempt is made to authenticate the signature. This flag has no effect on
files that are not digitally signed. |
dwPatchExpires
- Specifies the number of days that the patch may be applied.
Once the expiration date is reached, the patch may no longer be applied. A value of zero
specifies that the patch will never expire.
-
- dwReserved
- [in] Reserved; must be zero.
-
- lpszPassword
- [in] A pointer to a null-terminated string which specifies a
password that is used to secure the patch. A patch created with a password cannot be
applied unless the same password is provided to the ApplyPatchFile
function.
Note that the password is case sensitive. If no password is required, this parameter may
be NULL or point to an empty string.
-
- lpszOldFile
- [in] A pointer to a null-terminated string which specifies
the name of the reference file.
-
- lpszNewFile
- [in] A pointer to a null-terminated string which specifies
the name of the updated file. This file will be compared against the reference file, and
any changes are recorded in the patch file.
-
- lpfnCallback
- [in] Specifies the address of a callback function of type LPPATCHSTATUSPROC
that is called each time another portion of the patch file has been created. This
parameter can be NULL.
-
- For more information on the progress callback function, see PatchStatusProc.
-
- lParam
- [in] A 32-bit user-defined parameter that is passed through
the callback function. If no callback function has been specified, this parameter should
be zero.
Return Values
If the CreatePatchFile 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
To apply the patch file on a target system, use the ApplyPatchFile
function.
The higher the patch level specified, the longer it will
take the function to analyze the reference and updated files. It will also increase the
amount of memory allocated by the process. At the maximum patch level, a minimum of 64
megabytes of memory is required. It should be noted that in some cases, depending on the
internal structure of the file, specifying the maximum patch level may actually increase
the size of the resulting patch file. It is strongly recommended that applications use the
default patch level.
If neither PATCH_OPTION_COMPARE_FILETIME nor
PATCH_OPTION_IGNORE_FILETIME is specified, then PATCH_OPTION_COMPARE_FILETIME is the
default. If both PATCH_OPTION_COMPARE_FILETIME and PATCH_OPTION_IGNORE_FILETIME are
specified, then PATCH_OPTION_IGNORE_FILETIME takes precedence.
If neither PATCH_OPTION_COMPARE_VERSION nor
PATCH_OPTION_IGNORE_VERSION is specified, then PATCH_OPTION_COMPARE_VERSION is the
default. If both PATCH_OPTION_COMPARE_VERSION and PATCH_OPTION_IGNORE_VERSION are
specified, then PATCH_OPTION_IGNORE_VERSION takes precedence.
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
ApplyPatchFile, CreatePackage, GetPatchFileInformation
|
|