Merge Modules provide a standard method for you to deliver shared Windows Installer components, and setup logic to applications.
Merge modules must be merged into an installation package by using a merge tool. The best practice is to obtain a freely distributed merge tool, or purchase one of the merge tools that are available from independent software vendors, for example, you can use Mergemod.dll.
The following procedure shows you how to merge a merge module into a Windows Installer database by using Merge Module Automation.
To merge a module into a database
- Open a log file by using the OpenLog method.
This step is required only if you need to create a log file, or append an existing log file for the merge process.
- Open the .msi installation database by using the OpenDatabase method of the Merge Object.
This step is required.
The database that you open is the one that you want to receive the merge module.
- Open the .msm merge module by using the OpenModule method.
This step is required.
This is the merge module that is being merged into the database. A module must be opened before it can be merged with an installation database.
- Merge the module into the installation database by calling the Merge method or MergeEx method.
This step is required.
The Merge method or MergeEx method can only be called one time to merge a specific combination of .msi and .msm files.
Note The MergeEx method is only available in Mergemod.dll version 2.0 or later, and only when using the IMsmMerge2 interface.
- Retrieve the Errors property and examine the collection of Error objects it returns for merge conflicts or other errors.
You must resolve any errors.
The retrieval is nondestructive, and multiple instances of the error collection can be retrieved by repeatedly reading the Errors property.
- Associate the components of the merge module with the features by using the Connect method.
This step is only required if you have existing features and you want to add features to merge into the installation database.
A feature must exist before you call this method. For more information, see Connecting a Merge Module to Multiple Features.
- If necessary, extract source files from the module by doing one or more of the following:
- Use ExtractFiles or ExtractFilesEx to extract files from an embedded .cab file and then copy into a specified directory.
Note ExtractFilesEx requires Mergemod.dll version 2.0 or later.
- Use ExtractCAB to extract files from an embedded .cab file, and then save in a specified file.
- Use CreateSourceImage to extract files from a module, and then after the merge, copy to a source image on disk.
Note CreateSourceImage is only available in Mergemod.dll version 2.0 or later.
- Use ExtractFiles or ExtractFilesEx to extract files from an embedded .cab file and then copy into a specified directory.
- Close the current open merge module by using the CloseModule method.
This step is required.
- Close the open installation database by using the CloseDatabase method.
This step is required.
Closing a database clears all dependency information, but does not affect any errors that are not retrieved.
- Close the current log file by using the CloseLog method.
This step is required if you have an open log file.
After the module has been merged into the database using Mergemod.dll, the Media Table must be updated to describe the desired source image layout. The merge process provided by Mergemod.dll does not update the Media Table because the consumer of the merge module can select various ways to layout the source image.
See Also
Send comments about this topic to Microsoft
Build date: 8/13/2009
© 2009 Microsoft Corporation. All rights reserved.