Creating a Cabinet File

[This is preliminary documentation and subject to change.]

The ipenhsnd type library, Ipensnd.dll, includes an object, EnhCab, that you can use to create and investigate cabinet files. Cabinet files compress and package files together. This conserves bandwidth and ensures that your enhancement pages arrive together with their dependencies.

EnhCab provides several cabinet utility methods. For example, you can call EnhCab.NewCabinet to create a new cabinet file, EnhCab.AddFile to add files to a cabinet, and EnhCab.EnumerateCabinet to count the files stored in a cabinet. For a complete list of the methods provided by EnhCab, see the EnhCab reference topic.

The following example uses EnhCab to create a cabinet file that contains three enhancement files.

Dim ecab As EnhCab
Set ecab = New EnhCab
 
'Create a the cabinet file
ecab.NewCabinet "Cab1.cab", 2000000, 2000000, 1 
 
'Add two files to the new cabinet
ecab.AddFile "C:\file1.htm", "file1.htm"
ecab.AddFile "C:\file2.htm", "file1.htm"
 
'Close the cabinet file
ecab.CloseCabinet
 
'retrieve the number of files in the new cabinet
Dim numFiles As Long
ecab.EnumerateCabinet "C:\Cab1.cab", numFiles    'sets numFiles to 2 
 
'retrieve the filename of the first file in the cabinet
Dim firstFile As String
ecab.Filename 0, firstFile    'sets firstFile to "file1.htm"
 

If you are using the stream compiler objects to generate the stream, you can also use EnhEvent.onefile. Setting this property to True causes the stream compiler objects to package the file with its dependencies into a cabinet file and transmit them together.