CPatchFile::GetInformation

The CPatchFile::GetInformation function returns information about the specified patch file.

BOOL GetInformation(
LPCTSTR lpszPatchFile, // name of patch file
LPCTSTR lpszPassword, // password
DWORD dwOptions, // information options
LPPATCH_FILE_INFORMATION pfInfo // file information
);

Parameters

lpszPatchFile
[in] A pointer to a null-terminated string which specifies the name of the patch file to return information on.
 
lpszPassword
[in] A pointer to a null-terminated string which specifies the password that was used to secure the patch. Information about a patch file created with a password cannot be accessed unless it matches the password that was provided to the CPatchFile::Create function. Note that the password is case sensitive. If no password was specified, this parameter may be NULL or point to an empty string.
 
dwOptions
[in] Specifies what information is returned by the function. The following options are defined:
Value Description
PATCH_INFO_REFERENCE_FILE Return information about the reference file that was used to create the patch. This option cannot be combined with PATCH_INFO_UPDATE_FILE.
PATCH_INFO_UPDATE_FILE Return information about the update file that was used to create the patch. This option cannot be combined with PATCH_INFO_REFERENCE_FILE.
pfInfo
[in/out] A pointer to a PATCH_FILE_INFORMATION structure that will contain information about the specified patch file when the function returns.
 
Before calling the CPatchFile::GetInformation function, you must initialize the cbStructure member of the PATCH_FILE_INFORMATION data structure to sizeof(PATCH_FILE_INFORMATION).

Return Values

If the CPatchFile::GetInformation 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

The CPatchFile::GetInformation function is used to obtain information about the reference or updated file at the time the patch was created. This allows you to perform your own preliminary checks against a target file or display information about the patch file to a user.

To determine if a patch file is secured by a password, call the function with NULL as the password parameter. If the function fails, check the last error code to determine if it was because of an invalid password.

Example

// Determines if a patch file requires a password

PATCH_FILE_INFORMATION patchInfo;
BOOL bPasswordRequired = FALSE;
BOOL bResult;

patchInfo.cbStructure = sizeof(PATCH_FILE_INFORMATION);

bResult = GetInformation(lpszPatchFile,
                         NULL,
                         PATCH_INFO_REFERENCE_FILE,
                         &patchInfo);

if (bResult == FALSE)
{
    DWORD dwError = GetLastError();

    if (dwError == AP_ERROR_INVALID_PASSWORD)
        bPasswordRequired = TRUE;
    else
    {
        // This is not a patch file, or the file could
        // not be accessed for some other reason
    }
}

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

CPatchFile::Apply, CPatchFile::Create