MsiOpenDatabase

[This is preliminary documentation and subject to change.]

The MsiOpenDatabase function opens a database file for data access.

UINT MsiOpenDatabase(
  LPCTSTR szDatabasePath,  // path to database
  LPCTSTR szPersist,       // output database or predefined
                           // persist mode
  MSIHANDLE *phDatabase    // location to return database handle
); 
 

Parameters

szDatabasePath
Specifies the full path or relative path to the database file.
szPersist
Specifies the full path to the file or the persistence mode. You can use the szPersist parameter to direct the persistent output to a new file or to specify one of the following predefined persistence modes.
Value Meaning
MSIDBOPEN_CREATEDIRECT Create a new database, direct mode read/write.
MSIDBOPEN_CREATE Create a new database, transact mode read/write.
MSIDBOPEN_DIRECT Open a database direct read/write without transaction.
MSIDBOPEN_READONLY Open a database read-only, no persistent changes.
MSIDBOPEN_TRANSACT Open a database read/write in transaction mode.

phDatabase
Pointer to the location of the returned database handle.

Return Values

ERROR_CREATE_FAILED
The database could not be created.
ERROR_INVALID_PARAMETER
One of the parameters was invalid.
ERROR_OPEN_FAILED
The database could not be opened as requested.
ERROR_SUCCESS
The function succeeded.

Remarks

The MsiOpenDatabase function initiates database access. This function cannot be used for a running installation. The database must be opened in transaction, create, or direct mode for changes to be retained. Create mode creates a new installer database

Note  When a database is opened as the output of another database, the summary information stream of the output database is actually a read-only mirror of the original database, and, thus, cannot be changed. Additionally, it is not persisted with the database. To create or modify the summary information for the output database, it must be closed and reopened.

QuickInfo

  Windows NT: Requires version 4.0 or later. Available as a redistributable for Windows NT 4.0.
  Windows: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Windows CE: Unsupported.
  Header: Declared in msiquery.h.
  Import Library: Use msi.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

See Also

Database Access Reference, General Database Access Functions