Windows Installer API Functions
InstallShield 2020 » InstallScript Language Reference
You can call Windows Installer API functions from the main script and from within an InstallScript custom action. InstallScript supports these Windows Installer API functions:
Note:Most Windows Installer API functions take a handle to the currently running database as an argument. For an InstallScript custom action, the database handle is the HWND argument passed to the custom action. In an event-handler function, you can use the global variable ISMSI_HANDLE, which stores the handle to the running .msi database.
Note:For Windows APIs that require a buffer size and when the size of the value of the buffer size is greater than 1024 characters, a valid buffer size must be specified. For an example of how to write code for this scenario, refer to Changes in Behavior for Some MSI APIs That Are Called in InstallScript Custom Actions in the “Upgrading Projects from InstallShield 2011 or Earlier” topic.
MsiApplyPatch |
MsiGetLanguage |
MsiRecordSetInteger |
MsiCloseHandle |
MsiGetLastErrorRecord |
MsiRecordSetStream |
MsiCreateTransformSummaryInfo |
MsiGetMode |
MsiRecordSetString |
MsiDatabaseApplyTransform |
MsiGetProperty |
MsiSequence |
MsiDatabaseExport |
MsiGetSourcePath |
MsiSetComponentState |
MsiDatabaseGenerateTransform |
MsiGetSummaryInformation |
MsiSetFeatureAttributes |
MsiDatabaseGetPrimaryKeys |
MsiGetTargetPath |
MsiSetFeatureState |
MsiDatabaseImport |
MsiInstallProduct |
MsiSetInstallLevel |
MsiDatabaseIsTablePersistent |
MsiOpenDatabase |
MsiSetMode |
MsiDatabaseMerge |
MsiOpenPackage |
MsiSetProperty |
MsiDatabaseOpenView |
MsiPreviewBillboard |
MsiSetTargetPath |
MsiDoAction |
MsiPreviewDialog |
MsiSummaryInfoGetProperty |
MsiEnumComponentCosts |
MsiProcessMessage |
MsiSummaryInfoSetProperty |
MsiEvaluateCondition |
MsiRecordClearData |
MsiVerifyDiskSpace |
MsiFormatRecord |
MsiRecordDataSize |
MsiViewClose |
MsiGetActiveDatabase |
MsiRecordGetFieldCount |
MsiViewExecute |
MsiGetComponentState |
MsiRecordGetInteger |
MsiViewFetch |
MsiGetFeatureCost |
MsiRecordGetString |
MsiViewGetColumnInfo |
MsiGetFeatureState |
MsiRecordIsNull |
MsiViewGetError |
MsiGetFeatureValidStates |
MsiRecordReadStream |
|
Windows Installer API Functions by Category
This section includes the function signatures for the Windows Installer API functions available in InstallScript. See the Windows Installer Help for information about a function's usage, parameters, return values, and sequencing restrictions.
MSI Property and Mode Functions
Function |
Description |
prototype INT MsiSetProperty(HWND, BYVAL STRING, BYVAL STRING); |
Sets the value of a Windows Installer property. Creates the property if it does not exist. (For an example, see Getting or Setting Properties.) |
prototype INT MsiGetProductInfo(BYVAL STRING, BYVAL STRING, BYVAL STRING, BYREF INT); |
Returns product information for published and installed products. |
prototype INT MsiGetProperty(HWND, BYVAL STRING, BYREF STRING, BYREF INT); |
Gets the value of a Windows Installer property. Returns a null string ("") if the property does not exist. |
prototype INT MsiGetLanguage(HWND); |
Returns the numeric language ID for the running installation. |
prototype BOOL MsiGetMode(HWND, INT); |
Returns an internal boolean Installer state. |
prototype INT MsiSetMode(HWND, INT, BOOL); |
Sets an internal boolean Installer state. |
Feature and Component Functions
Function |
Description |
prototype INT MsiGetFeatureState(HWND, BYVAL STRING, BYREF INT, BYREF INT); |
Gets the installation state and action state of a feature. |
prototype INT MsiSetFeatureState(HWND, BYVAL STRING, INT); |
Sets the installation state of a feature. |
prototype INT MsiSetFeatureAttributes(HWND, BYVAL STRING, INT); |
Sets the attributes for a feature. |
prototype INT MsiGetFeatureValidStates(HWND, BYVAL STRING, BYREF INT); |
Returns a set of bit flags representing the valid installation states of a feature. |
prototype INT MsiGetComponentState(HWND, BYVAL STRING, BYREF INT, BYREF INT); |
Gets the installation state and action state of a component. |
prototype INT MsiSetComponentState(HWND, BYVAL STRING, INT); |
Sets the installation state of a component. |
prototype INT MsiGetFeatureCost(HWND, BYVAL STRING, INT, INT, BYREF INT); |
Returns the disk cost of a feature (in units of 512 bytes), and optionally its parent and child features. |
prototype INT MsiSetInstallLevel(HWND, INT); |
Sets the install level for the entire product. |
Directory Functions
Function |
Description |
prototype INT MsiGetSourcePath(HWND, BYVAL STRING, BYREF STRING, BYREF INT); |
Returns the full source path for a directory listed in the Directory table. (The Directory table is exposed in the Direct Editor.) |
prototype INT MsiGetTargetPath(HWND, BYVAL STRING, BYREF STRING, BYREF INT); |
Returns the full target path for a directory listed in the Directory table. |
prototype INT MsiSetTargetPath(HWND, BYVAL STRING, BYVAL STRING); |
Sets the full target path for a directory listed in the Directory table. |
prototype INT MsiVerifyDiskSpace(HWND); |
Verifies if sufficient disk space exists for the current installation. |
Database Functions
With the exception of MsiGetActiveDatabase, the first HWND argument in most of these functions is a handle to a specific database view or record.
Function |
Description |
prototype INT MsiEvaluateCondition(HWND); |
Evaluates a conditional expression that contains property names and values. |
prototype INT MsiGetActiveDatabase(HWND); |
Obtains a handle to the running .msi database, which you can use to open database views. |
prototype INT MsiDatabaseApplyTransform(HWND, BYVAL STRING, INT); |
Applies a transform to a database. A transform is a way of recording changes to a database without altering the original database. |
prototype INT MsiDatabaseExport(HWND, BYVAL STRING, BYVAL STRING, BYVAL STRING); |
Exports an installer table from an open database to a text archive file. |
prototype INT MsiDatabaseGenerateTransform(HWND, BYVAL STRING, INT, INT); |
Generates a transform file of differences between two databases. A transform is a way of recording changes to a database without altering the original database. |
prototype INT MsiDatabaseGetPrimaryKeys(HWND, BYVAL STRING, BYREF HWND); |
Returns a record containing the names of all the primary key columns for a specified table. This function returns a handle that should be closed using MsiCloseHandle. |
prototype INT MsiDatabaseImport(HWND, BYVAL STRING, BYVAL STRING); |
Imports an installer text archive table into an open database. |
prototype INT MsiDatabaseIsTablePersistent(HWND, BYVAL STRING); |
Returns an enumeration describing the state of a particular table. |
prototype INT MsiDatabaseMerge(HWND, HWND, BYVAL STRING); |
Merges two databases together, allowing duplicate rows. |
prototype INT MsiDatabaseOpenView(HWND, BYVAL STRING, BYREF INT); |
Prepares a database query, creating a view object. |
prototype INT MsiFormatRecord(HWND, HWND, BYREF STRING, BYREF INT); |
Formats record field data and properties using a format string. |
prototype INT MsiViewModify(HWND, INT, HWND); |
Modifies a database record. For a running installation, only temporary database changes are allowed. |
prototype INT MsiOpenDatabase(BYVAL STRING, BYVAL STRING, BYREF HWND); |
Opens a database file for data access. This function returns a handle that should be closed using MsiCloseHandle. |
prototype INT MsiViewClose(HWND); |
Closes an executed database view. |
prototype INT MsiViewExecute(HWND, HWND); |
Executes a SQL query. |
prototype INT MsiViewFetch(HWND, BYREF HWND); |
Fetches a record for the current database view. |
prototype INT MsiRecordGetString(HWND, INT, BYREF STRING, BYREF INT); |
Returns the string stored in a specific field of the specified record. |
prototype INT MsiRecordSetString(HWND, INT, BYVAL STRING); |
Sets the string stored in a specific field of the specified record. |
prototype INT MsiRecordReadStream(HWND, INT, CHAR, POINTER); |
Returns the string value of a record field. |
prototype INT MsiRecordSetStream(HWND, INT, BYVAL BINARY); |
Sets a record stream field from a file. Stream data cannot be inserted into temporary fields. |
prototype INT MsiRecordGetInteger(HWND, INT); |
Returns the integer stored in a specific field of the specified record. |
prototype INT MsiRecordSetInteger(HWND, INT, INT); |
Sets the integer stored in a specific field of the specified record. |
prototype INT MsiViewGetColumnInfo(HWND, INT, BYREF INT); |
Returns a record containing database column names or definitions. |
prototype INT MsiRecordGetFieldCount(HWND); |
Returns the number of fields (columns) in a record. |
prototype INT MsiCloseHandle(HWND); |
Closes a database, view, or record handle. |
prototype MsiCloseAllHandles( ); |
Closes all open handles. Provided for diagnostic purposes, and should not be called for general cleanup. |
prototype INT MsiViewGetError(HWND, BYREF STRING, BYREF INT); |
Returns an error code for an error generated by MsiViewModify. |
Summary Information Stream Management Functions
Function |
Description |
prototype MsiGetSummaryInformation(HWND, BYVAL STRING, INT, BYREF HWND); |
Obtains a handle to summary information data for an installer database. This function returns a handle that should be closed using MsiCloseHandle. |
prototype INT MsiSummaryInfoGetProperty(HWND, INT, BYREF INT, BYREF INT, POINTER, BYREF STRING, BYREF INT); |
Gets a single property from the summary information. |
prototype INT MsiSummaryInfoSetProperty(HWND, INT, INT, INT, POINTER, BYREF STRING); |
Sets a single summary information property. |
Miscellaneous Functions
Function |
Description |
prototype INT MsiApplyPatch(BYVAL STRING, BYVAL STRING, INT, BYVAL STRING); |
For each product listed by the patch package as eligible to receive the patch, the MsiApplyPatch function invokes an installation and sets the PATCH property to the path of the patch package. |
prototype HWND MsiCreateRecord(INT); |
Creates a new record object with the specified number of fields. This function returns a handle that should be closed using MsiCloseHandle. |
prototype INT MsiDoAction(HWND, BYVAL STRING); |
Executes a built-in action, custom action, or user-interface wizard action. |
prototype INT MsiEvaluateCondition(HWND, BYVAL STRING); |
Evaluates a conditional expression containing property names and values. |
prototype INT MsiInstallProduct(BYVAL STRING, BYVAL STRING); |
Installs or uninstalls a product. |
prototype INT MsiOpenPackage(BYVAL STRING, BYREF HWND); |
Opens a package for use with the functions that access the product database. The MsiCloseHandle function must be called with the handle when the handle is no longer needed. |
prototype INT MsiPreviewBillboard(HWND, BYVAL STRING, BYVAL STRING); |
Displays a billboard within a host control in the displayed dialog. Supplying a null billboard name removes any billboard displayed. |
prototype INT MsiPreviewDialog(HWND, BYVAL STRING); |
Displays a dialog as modeless and inactive. |
prototype int MsiProcessMessage(HWND, int, HWND); |
Sends an error record to the installer for processing. |
prototype INT MsiSequence(HWND, BYVAL STRING, INT); |
Executes another action sequence, as described in the specified table. |
See Also