GetPackageFileDirectory

The GetPackageFileDirectory function returns the installation directory for the specified file.

UINT GetPackageFileDirectory(
HPACKAGE hPackage, // handle to package file
BOOL bExpandDirectory, // expand directory macros
DWORD dwFilePlatform, // file platform
DWORD dwFileChecksum, // file checksum
LPCTSTR lpszFileName, // file name in package
LPTSTR lpszDirectory, // installation directory buffer
UINT nMaxLength // buffer size
);

Parameters

hPackage
[in] Handle to an open package file.
 
bExpandDirectory
[in] Specifies if the installation directory should be expanded, resolving any environment variables or folder macros.
 
dwFilePlatform
[in] Specifies the target platform for the file.
 
This may be one of the following values:
Value Description
PACKAGE_FILE_PLATFORM_DEFAULT Return the installation directory for 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.
dwFileChecksum
[in] Specifies the 32-bit checksum for the file. If the package contains multiple file versions, this value is used to uniquely identify the file. This parameter is ignored if the PACKAGE_OPTION_MULTIPLE_VERSIONS package option has not been enabled or if the parameter value is zero.
 
lpszFileName
[in] A pointer to a null-terminated string which specifies the package file.
 
lpszInstallPath
[out] A pointer to a string buffer that will contain the installation directory for the specified file when the function returns. It is recommended that this buffer be at least MAX_PATH bytes in size. If this parameter is NULL, the function will return the length of the installation directory.
 
nMaxLength
[in] The maximum number of characters which may be stored in the lpszInstallPath buffer.

Return Values

If the GetPackageFileDirectory function succeeds, it will return the length of the installation directory for the specified file, not including the terminating null byte.

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

Remarks

The GetPackageFileDirectory function will return the installation directory for the specified file. If the bExpandDirectory parameter is non-zero, any environment variables or folder macros will be expanded. These are special tokens which are replaced when the package is applied on the target system. See the SetPackageFileDirectory function for more information about folder macros.

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

SetPackageFileDirectory