MsiOpenPackageA function (msi.h)

The MsiOpenPackage function opens a package to use with the functions that access the product database. The MsiCloseHandle function must be called with the handle when the handle is not needed.

Note  Initialize COM on the same thread before calling the MsiOpenPackage, MsiOpenPackageEx, or MsiOpenProduct function.

 

Syntax

UINT MsiOpenPackageA(
  [in]  LPCSTR    szPackagePath,
  [out] MSIHANDLE *hProduct
);

Parameters

[in] szPackagePath

The path to the package.

[out] hProduct

A pointer to a variable that receives the product handle.

Return value

Value Meaning
ERROR_BAD_CONFIGURATION
The configuration information is corrupt.
ERROR_INSTALL_FAILURE
The product could not be opened.
ERROR_INSTALL_REMOTE_PROHIBITED
Windows Installer does not permit installation from a remote desktop connection.
ERROR_INVALID_PARAMETER
An invalid parameter is passed to the function.
ERROR_SUCCESS
The function completes successfully.
 

If this function fails, it may return a system error code. For more information, see System Error Codes.

Remarks

MsiOpenPackage can accept an opened database handle in the form "#nnnn", where nnnn is the database handle in string form, i.e. #123, instead of a path to the package. This is intended for development tasks such as running validation actions, or for use with database management tools.

Note

The msi.h header defines MsiOpenPackage as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows Installer 5.0 on Windows Server 2012, Windows 8, Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003 or Windows XP. See the Windows Installer Run-Time Requirements for information about the minimum Windows service pack that is required by a Windows Installer version.
Target Platform Windows
Header msi.h
Library Msi.lib
DLL Msi.dll

See also

Product Query Functions