FindFirstPackageFile

The FindFirstPackageFile function returns the first file in the package that matches the specified search criteria.

BOOL WINAPI FindFirstPackageFile(
HPACKAGE hPackage, // handle to package file
LPCTSTR lpszFindFile, // file specification
DWORD dwFilePlatform, // file platform
DWORD dwFindOptions, // find options
LPPACKAGE_FILE_INFORMATION lpFileInfo // file information
);

Parameters

hPackage
[in] Handle to an open package file.
 
lpszFindFile
[in] A pointer to a null-terminated string which specifies the name of the file to search for. This value may contain a directory specification, as well wildcards.
 
dwFilePlatform
[in] Specifies the target platform for the file.
 
This may be one of the following values:
Value Description
PACKAGE_FILE_PLATFORM_DEFAULT Find the file which is targeted for the current platform.
PACKAGE_FILE_PLATFORM_WIN95 The file may be applied to a system running Windows 95.
PACKAGE_FILE_PLATFORM_WIN98 The file may be applied to a system running Windows 98 or Windows 98 SE.
PACKAGE_FILE_PLATFORM_WINME The file may be applied to a system running Windows ME.
PACKAGE_FILE_PLATFORM_WINNT40 The file may be applied to a system running Windows NT 4.0.
PACKAGE_FILE_PLATFORM_WIN2000 The file may be applied to a system running Windows 2000.
PACKAGE_FILE_PLATFORM_WINXP The file may be applied to a system running Windows XP.
In addition to the above platform-specific values, there are predefined values which specify platform groups:
 
Value Description
PACKAGE_FILE_PLATFORM_WIN32 The file may be applied to any 32-bit version of the Windows operating system.
PACKAGE_FILE_PLATFORM_WIN9X The file may be applied to any system running Windows 95, Windows 98 or Windows ME. The file will not be applied on a system running Windows NT, Windows 2000 or Windows XP.
PACKAGE_FILE_PLATFORM_WINNT The file may be applied to any system running Windows NT, Windows 2000 or Windows XP. The file 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.
dwFindOptions
[in] A value which specifies one or more options.
 
The following option may be used:
 
Value Description
PACKAGE_FIND_RECURSIVE Search recursively through the package, looking for matches in the specified directory as well as all subdirectories; to search the entire package for a given file, this option should be specified and the lpszFindFile parameter should not include a directory as part of the file name.
lpFileInfo
[in/out] A pointer to a PACKAGE_FILE_INFORMATION structure that will contain information about the file. Note that the cbStructure member must be initialized to the size of the structure that is being passed to the function.

Return Values

If the FindFirstPackageFile 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 FindFirstPackageFile function will return FALSE if no files in the package match the specified search criteria.

Files that have been deleted from the package will not be returned by this function.

The standard wildcard characters (*,?) may be used in the file specification when searching for a file. File names are not case sensitive.

The installation directory is not considered during the search for the file.

Example

// Delete all executable files from the package
PACKAGE_FILE_INFORMATION pfInfo;
DWORD dwError = ERROR_SUCCESS;
BOOL bResult;

pfInfo.cbStructure = sizeof(PACKAGE_FILE_INFORMATION);
bResult = FindFirstPackageFile(hPackage, _T("*.exe"),
                               PACKAGE_FILE_PLATFORM_DEFAULT,
                               PACKAGE_FIND_RECURSIVE, &pfInfo);

while (bResult)
{
       bResult = DeletePackageFile(hPackage,
                                  PACKAGE_FILE_PLATFORM_DEFAULT,
                                  pfInfo.dwChecksum,
                                  pfInfo.szFileName);

       if (bResult == FALSE)
       {
           dwError = GetLastError();
           break;
       }

       bResult = FindNextPackageFile(hPackage, &pfInfo);
}

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

FindNextPackageFile, GetFirstPackageFile