Nondeferred custom actions that call dynamic-link libraries or scripts may access a running installation to query or modify the attributes of the current installation session. Only one Session object can exist for each process, and custom action scripts must not attempt to create another session.
Custom actions can only add, modify, or remove temporary rows, columns, or tables from a database. Custom actions cannot modify persistent data in a database, for example, data that is a part of the database stored on disk.
To access a running installation, custom actions that call dynamic-link libraries (DLL) are passed a handle of the type MSIHANDLE for the current session as the only argument to the DLL entry point named in the Target column of the CustomAction Table. Because the installer provides this handle, the custom action should not close it, for example, to receive the handle hInstall from the installer, the custom action function is declared as follows.
UINT __stdcall CustomAction(MSIHANDLE hInstall)
For read-only access to the current database obtain the database handle by calling MsiGetActiveDatabase. For more information, see Obtaining a Database Handle.
Custom actions written in VBScript or JScript can access the current installation session by using the Session Object. The installer creates a Session object named "Session" that references the current installation. For read-only access to the current database use the Database property of the Session object.
Because a script is run from the context of the Session object, it is not always necessary to fully qualify properties and methods. In the following example, when using VBScript, the Me reference can replace the Session object, for example, the following three lines are equivalent.
Session.SetInstallLevel 1
Me.SetInstallLevel 1
SetInstallLevel 1
You cannot access the current installer session from custom actions that call executable files launched with a command-line, for example, Custom Action Type 2 and Custom Action Type 18.
Deferred Execution Custom Actions
You cannot access the current installer session or all property data from a deferred execution custom action. For more information, see Obtaining Context Information for Deferred Execution Custom Actions.
See Also
Send comments about this topic to Microsoft
Build date: 8/13/2009
© 2009 Microsoft Corporation. All rights reserved.