This section describes how to create a CAB file that distributes ATL and MFC controls over the Internet. If you need more information about the CAB file, for more information, see the compressed Files in the Platform SDK documentation (in the MSDN Library/Setup and System Administration/Setup API/Overview/Cabinet Files Directories ).
Create a CAB file:
- Create an INF file.
- Run the CABARC utility.
Create an INF file
The INF file is a text file used to specify the file (such as a DLL file or other OCX files) to be displayed or downloaded when the control is running ). The INF file allows you to bind all the required files to a compressed CAB file. By default, files with the same version number as existing files on the user's hard disk are not downloaded. For more information about the INF file and its options, including how to create a platform-independent INF file, see the INF file in the Platform SDK documentation and use the INF file (in the MSDN Library/Setup and System Administration/Setup API/Overview/Setup Applications directory ).
For example, the following INF file is used to create a CAB file for the ATL Polygon control. You can download the atl polygon sample file from Visual C ++ CD and generate the MinSize version to generate POLYGON. DLL. If the MinSize version of the Polygon control is generated, another DLL, ATL. DLL, is required. Because you need to register ATL. DLL before POLYGON. DLL, place ATL. DLL first in the INF file:
; Sample INF file for POLYGON.DLL[version] ; version signature (same for both NT and Win95) do not removesignature="$CHICAGO$"AdvancedINF=2.0 [Add.Code]polygon.dll=polygon.dllatl.dll=atl.dll; needed DLL[atl.dll]file-win32-x86=thiscabFileVersion=2,00,0,7024DestDir=11RegisterServer=yes [polygon.dll]file-win32-x86=thiscabclsid={4CBBC676-507F-11D0-B98B-000000000000} FileVersion=1,0,0,1 RegisterServer=yes ; end of INF file
This INF file specifies that the specified version of ATL. DLL needs to be installed on the system. If ATL. DLL does not exist in the system, it will be downloaded from the CAB file created with this INF. "Thiscab" is a keyword that indicates that the CAB contains this INF. You can also specify an absolute or relative path to download the required DLL from an HTTP Location, for example:
file-win32-x86=http://example.microsoft.com/mydir/NEEDED.DLL
The keyword file-win32-x86 identifies the platform as x86-specific.
You can right-click a file in Windows resource manager to get the file version number. Select "properties" from the displayed list, and then select the "version" tab in the displayed dialog box. Sometimes you need to insert an additional 0 in the file version. For example, in the dialog box, the version number of ATL. DLL is 2.00.7024. In the INF file, this is changed to 2, 00, 0, 7024.
"DestDir" is the directory where the file to be loaded is located: 11 specify the SYSTEM directory as WINDOWS/SYSTEM or WINNT/SYSTEM32; 10 specify the Windows directory, WINDOWS or WINNT. If no DestDir is specified, the code is installed in the fixed OCCACHE directory.
"Clsid" is the CLSID of the control to be installed.
After the INF file is created, run the CABARC utility (which can be found in the Mssdk \ Bin directory) to create the CAB file. CABARC should be run in the directory containing the source file. On the command line, sort the source files in the order they appear in INF and put the INF file at the end. For example, to generate the CAB file of the Polygon control from the above INF file, use the following command:
C:\MSSDK\BIN\CABARC -s 6144 POLYGON.CAB ATL.DLL POLYGON.DLL POLYGON.INF
The POLYGON. CAB file contains a compressed version of ATL. DLL and POLYGON. DLL, as well as the information required to decompress it in the POLYGON. INF file.
For examples of how to analyze and extract components from the CAB file, see the CabView example in MSDN Online Code Center on the http://msdn.microsoft.com/visualc/downloads/samples.asp (select the CabView link.
The DLL files that need to be included in the MFC control include MSVCRT. DLL, MFC42.DLL, and OLEPRO32.DLL.
Run CABARC Utility
You can find the CABARC utility in the Mssdk \ Bin directory. For example:
C:\MSSDK\BIN\CABARC -s 6144 n MYCTL.CAB NEEDED1.DLL NEEDED2.DLL MYCTL.OCX MYCTL.INF
CABARC creates a CAB file called MYCTL. CAB.
CABARC should be run in a directory containing the source files (INF, OCX, and DLL files. Files archived in the CAB file should be listed in the command line in the same order as they are listed in the INF file. In the above example, the INF file should list NEEDED1.DLL in the first place, then NEEDED2.DLL and MYCTL. OCX.
-SOption to retain the space used for code signature in the compressed file.NCommand to create a CAB file.