| 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 // Apply a patch file, creating the updated version of
// a file from the original version
LPCTSTR lpszPatchFile = _T("house.pat"); // patch file
LPCTSTR lpszPassword = _T("secret"); // patch file password
LPCTSTR lpszFileName = _T("house.mdb"); // original version of database
DWORD dwOptions;
BOOL bResult;
dwOptions = PATCH_OPTION_BACKUP_FILE |
PATCH_OPTION_IGNORE_FILETIME;
bResult = ApplyPatchFile(lpszPatchFile, // patch file name
dwOptions, // patch options
0, // reserved
lpszPassword, // patch password
lpszFileName, // original file
NULL, // updated file
NULL, // callback function
0); // callback parameter
Many of the parameters are similar to those used with the CreatePatchFile function, however there are some notable differences. In this case, we do specify some options, and no file name is specified for the updated file. The first option that is specified, Because the output (updated) file name parameter was specified as NULL, this tells the
function that you wish to overwrite the original version of the file with the updated
version. In this example, before the function is called, the file
If the ApplyPatchFile function succeeds, it will return a non-zero value. If the function fails, it will return a value of zero and the GetLastError function can be used to determine the cause of the error. The same code used in the CreatePatchFile example can be used to obtain a descriptive error string. |
||