Article ID: 167158 - Last Review: October 16, 2007 - Revision: 5.2 How to package MFC controls in a Web pageThis article was previously published under Q167158 On This PageSUMMARY
When you embed ActiveX Controls in a Web page using the OBJECT tag, the
CODEBASE attribute used to specify the download location can point to a
.cab file. This is the recommended way to package MFC ActiveX Controls.
Packaging an MFC ActiveX Control in a cabinet file allows an .inf file to
be included to control installation of the ActiveX Control, allows for
dependent DLLs to be named and a location for them provided, allows for
code signing, and automatically compresses the code for quicker download.
MORE INFORMATION
ActiveX controls are embedded in Web pages using the OBJECT tag. The
CODEBASE attribute of the OBJECT tag specifies the location from which to
download the control. CODEBASE can point to a number of different file
types successfully.
For instance, CODEBASE can point directly to an .ocx file as follows: Another alternative is for CODEBASE to point to an .inf file, for example: The best solution is for CODEBASE to point to a cabinet file. With this method, supporting DLLs can be referenced and the cabinet file signed. NOTE: If the directions below for referencing the MFC DLLs are followed, the MFC DLLs will not be downloaded if they already exist on the client. The CODEBASE line will resemble the following: Cab Packaging OverviewIn the Cabinet Software Development Kit (also called Cabinet SDK, or CAB Development Kit) you will find the necessary tools to construct cabinet (.cab) files. See the following Microsoft Web site:
Microsoft Cabinet SDK
The cabinet file that CODEBASE points to should contain the .ocx file and
an .inf file that will control the installation of the ActiveX Control.
Dependent DLLs that may already exist on the system, such as the MFC DLLs,
should not be included in this cabinet file. Instead, the MFC DLLs, and
other dependent DLLs, should be packaged in separate cabinet files and
referenced by the control's .inf file. The following example illustrates
how to package the MFC Spindial sample control.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncabsdk/html/cabdl.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncabsdk/html/cabdl.asp) The OBJECT tag to include the Spindial control in a Web page resembles the following: C:\CabDevKit\cabarc.exe N spindial.cab spindial.ocx spindial.inf
VC 4.1 and earlier, use:http://activex.microsoft.com/controls/vc/mfc40.cab
(http://activex.microsoft.com/controls/vc/mfc40.cab)
Olepro32.dll 4,1,0,6038 Mfc40.dll 4,1,0,6139 Msvcrt40.dll 4,10,0,6038 VC 4.2b and earlier, use:http://activex.microsoft.com/controls/vc/mfc42.cab
(http://activex.microsoft.com/controls/vc/mfc42.cab)
Olepro32.dll 4,2,0,6068 Mfc42.dll 4,2,0,6256 Msvcrt.dll 4,20,0,6164 VC 5.0, use:http://activex.microsoft.com/controls/vc/mfc42.cab
(http://activex.microsoft.com/controls/vc/mfc42.cab)
Olepro32.dll 5,0,4055,1 Mfc42.dll 4,21,0,7022 Msvcrt.dll 5,0,0,7022 VC 5.0sp1, use:http://activex.microsoft.com/controls/vc/mfc42.cab
(http://activex.microsoft.com/controls/vc/mfc42.cab)
Olepro32.dll 5,0,4055,1 Mfc42.dll 4,21,0,7160 Msvcrt.dll 5,0,0,7128 VC 5.0sp2, use:http://activex.microsoft.com/controls/vc/mfc42.cab
(http://activex.microsoft.com/controls/vc/mfc42.cab)
Olepro32.dll 5,0,4055,1 Mfc42.dll 4,21,0,7160 Msvcrt.dll 5,0,0,7128 VC 5.0sp3, use:http://activex.microsoft.com/controls/vc/mfc42.cab
(http://activex.microsoft.com/controls/vc/mfc42.cab)
Olepro32.dll 5,0,4230,1 Mfc42.dll 4,21,0,7303 Msvcrt.dll 5,0,0,7303 VC 6.0, use:http://activex.microsoft.com/comtrols/vc/mfc42.cab
(http://activex.microsoft.com/controls/vc/mfc42.cab)
Olepro32.dll 5,0,4261,0 Mfc42.dll 6,0,8168,0 Msvcrt.dll 6,0,8168,0 Notice that all versions of MFC between 4.2 and 6.0 use Mfc42.cab. This .cab file always contains the latest version of the DLLs because they are backward-compatible. If you are not compiling with a later build of MFC, you may not want to specify the latest FileVersion. Doing so may trigger an unnecessary download of the MFC DLLs. REFERENCES
For more information, visit the following Microsoft Developer Network (MSDN) Web sites:
Packaging ActiveX Controls http://msdn.microsoft.com/library/default.asp?url=/workshop/components/activex/packaging.asp?frame=true (http://msdn.microsoft.com/library/default.asp?url=/workshop/components/activex/packaging.asp?frame=true)
Safe Initialization and Scripting for ActiveX Controls http://msdn2.microsoft.com/en-us/library/Aa751977.aspx?frame=true#iobjsafe (http://msdn2.microsoft.com/en-us/library/Aa751977.aspx?frame=true#iobjsafe)
Signing Code with Microsoft Authenticode Technology http://msdn2.microsoft.com/en-us/library/ms537358.aspx (http://msdn2.microsoft.com/en-us/library/ms537358.aspx)
Using ActiveX Controls to Automate Your Web Pages
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
http://msdn.microsoft.com/library/default.asp?url=/workshop/components/activex/tutorial.asp?frame=true (http://msdn.microsoft.com/library/default.asp?url=/workshop/components/activex/tutorial.asp?frame=true) 264570
(http://support.microsoft.com/kb/264570/
)
INFO: WebCast: How Does Internet Component Download Work?
APPLIES TO
| Article Translations
|


Back to the top
