Rediger

Del via


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

  1. Use a cabinet creation tool to compress the source files into a cabinet file. See Cabinet Files.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. To add the cabinet to the installation package from a program open a view on the _Streams table of the database using MsiDatabaseOpenView.
  9. 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: #.
  10. Use MsiRecordSetStream to set the Data column of the _Streams table to the cabinet's data.
  11. Use MsiViewModify to update the record in the _Streams table.
  12. 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.