Including a Cabinet File in an Installation
This section describes including cabinet files in installations. For more information, see Using Cabinets and Compressed Sources.
To include a cabinet file in an installation package
- Use a cabinet creation tool to compress the source files into a cabinet file. See Cabinet Files.
- The cabinet file must either be located in a data stream inside the .msi file or in a separate cabinet file located at the root of the source tree specified by the Directory Table.
- Determine whether the source is to be a compressed type or a mixed type that has both uncompressed and compressed files. See Compressed and Uncompressed Sources. Depending on the type of source image, set the compressed or uncompressed flag bits of the Word Count Summary Property.
- Add a record to the File table for each of the files in the cabinet. Enter a file key in the File column that exactly matches the file key of the file in the cabinet. The file keys are case-sensitive. The file installation sequence in the File table and the cabinet must also be the same. The file sequence is specified by the sequence number in the Sequence column. To arrive at the sequence number for the first file in the cabinet, do the following. Find the existing record in the Media table having the greatest value in the DiskID column. The LastSequence field of this record gives the last file sequence number used on the media. In the File table, assign the first file of the new cabinet a sequence number that is greater than this. Assign sequence numbers to all of the remaining files in the same order as in the cabinet file. For a description of the remaining record fields, see File table.
- Add a record to the Media table for the cabinet. Specify a value in the DiskID field of this new record that is greater than the largest DiskID value already existing in the table. Put the name of the cabinet into the Cabinet field. This name must be in the form of a Cabinet data type. Prefix the name with a number sign "#" if the cabinet is a data stream stored in the .msi file. Note that if the cabinet is a data stream, the name of the cabinet is case-sensitive. If the cabinet is a separate file, the name of the file is not case-sensitive.
- Determine the greatest file sequence number in the new cabinet by checking the Sequence column of the updated File table. Enter a value that is greater than this into the LastSequence field of the new record of the Media table. For a description of the remaining record fields, see Media table.
- You can store the cabinet file in the installation package either by using a tool such as Msidb.exe or by using the installer's Database Functions. The following four steps explain how to add the cabinet from a program by using the database functions.
- To add the cabinet to the installation package from a program open a view on the _Streams table of the database using MsiDatabaseOpenView.
- Use MsiRecordSetString to set the Name column of the _Streams table to the name appearing in the Cabinet column of the Media table. Omit the number sign: #.
- Use MsiRecordSetStream to set the Data column of the _Streams table to the cabinet's data.
- Use MsiViewModify to update the record in the _Streams table.
- To use Msidb.exe to add the cabinet file Mycab.cab to the installation package named Mydatabase.msi, use the following command line: Msidb.exe -d mydatabase.msi -a mycab.cab. In this case, the Cabinet column of the Media table should contain the string: #mycab.cab.