How To Package MFC Controls for Use Over the InternetArticle ID: Q157959Creation Date: 21-OCT-1996 Revision Date: 10-DEC-1996
The information in this article applies to:
SUMMARY
ActiveX Controls are embedded in Web pages using the <OBJECT> tag. The
CODEBASE parameter of the <OBJECT> tag specifies the location from which
the control can be downloaded. CODEBASE can point at a number of different
file types successfully:
CODEBASE="http://www.somesite.com/somecontrol.ocx#version=4,70,0,1086" This solution relies on any supporting DLLs already being on the client machine. For Internet Explorer 3.0 and MFC ActiveX Controls built with Visual C++ 4.0 and 4.1, this is a good solution. Internet Explorer 3.0 ships with the supporting DLLs for Visual C++ 4.0 and 4.1 controls. If another Internet browser that is ActiveX-Control capable is used to view this control, this may not be the best solution. CODEBASE="http://www.notasafesite.com/doyoutrustme.inf An .inf file will control the installation of an .ocx file and its supporting files. This method is not recommended because it is not possible to sign an .inf file. Please see the REFERENCES section below for references on code signing. CODEBASE="http://www.somesite.com/acontrol.cab#version=1,2,0,0" Note that the #Version information applies to the control specified by the CLASSID parameter of the <OBJECT> tag.
MORE INFORMATION
Cab Packaging Overview The CABinet Development Kit can be obtained from http://www.microsoft.com/workshop/java/cab-f.htm. In this kit, you will find the necessary tools to construct cabinet files. The cabinet file pointed to by CODEBASE 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 should not be included in this cabinet file. The MFC DLLs are such a case: they should be packaged in a separate cabinet file and referred to by the controlling .inf file. The following example illustrates how to package the MFC Spindial sample control: The <OBJECT> tag to include the Spindial control in a Web page will look similar to the following:
<OBJECT ID="Spindial1" WIDTH=100 HEIGHT=51
CLASSID="CLSID:06889605-B8D0-101A-91F1-00608CEAD5B3"
CODEBASE="http://yoursite/spindial.cab#Version=1,0,0,001">
<PARAM NAME="_Version" VALUE="65536">
<PARAM NAME="_ExtentX" VALUE="2646">
<PARAM NAME="_ExtentY" VALUE="1323">
<PARAM NAME="_StockProps" VALUE="0">
<PARAM NAME="NeedlePosition" VALUE="2">
</OBJECT>
In this case, Spindial.cab contains two files: Spindial.ocx and
Spindial.inf. The command to build this cabinet file is similar to the
following, depending on the path to your installation of the CABinet
Development Kit:
C:\CabDevKit\cabarc.exe -s 6144 N spindial.cab spindial.ocx spindial.infThe "-s 6144" parameter passed to Cabarc.exe reserves space in the cabinet for code signing. The following is an example .inf file for the MFC Spindial control. This .inf file can be modified to download any MFC ActiveX Control by changing Spindial s information to the desired MFC ActiveX Control s information. See comments below.
; ========================= spindial.inf =========================
; This inf file controls the installation of the MFC Spindial
; control.
; This control has been compiled with Visual C++ version 4.2. The
; FileVersion tags in the dependent DLLs section on this file reflect
; this requirement.
; note - keep comments in .inf files on separate lines
[version]
; version signature (same for both NT and Windows 95) do not remove
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
spindial.ocx=spindial.ocx
; These are the necessary supporting DLLs for MFC 4.2 ActiveX Controls
msvcrt.dll=msvcrt.dll
mfc42.dll=mfc42.dll
olepro32.dll=olepro32.dll
; thiscab is a keyword that, in this case, means that spindial.ocx
; can be found in the same .cab file as this .inf file
; file-win32-x86 is an x86 platform specific identifier
; See the ActiveX SDK - ActiveX Controls - Internet Component Download -
; Packaging component code for automatic download
[spindial.ocx]
file-win32-x86=thiscab
; *** add your controls CLSID here ***
clsid={06889605-B8D0-101A-91F1-00608CEAD5B3}
; add your ocx s file version here
FileVersion=1,0,0,001
RegisterServer=yes
; dependent DLLs
[msvcrt.dll]
; This is an example of conditional hook. The hook only gets processed
; if msvcrt.dll of the specified version is absent on client machine.
FileVersion=4,20,0,6164
hook=mfc42installer
[mfc42.dll]
FileVersion=4,2,0,6256
hook=mfc42installer
[olepro32.dll]
FileVersion=4,2,0,6068
hook=mfc42installer
[mfc42installer]
file-win32-x86=http://activex.microsoft.com/controls/vc/mfc42.cab
; If dependent DLLs are packaged directly into the above cabinet file
; along with an .inf file, specify that .inf file to run as follows:
;InfFile=mfc42.inf
; The mfc42.cab file actually contains a self extracting executable.
; In this case we specify a run= command.
run=%EXTRACT_DIR%\mfc42.exe
; ====================== end of spindial.inf ======================
Note the location for the MFC 4.2 DLLs:
[mfc42installer] file-win32-x86=http://activex.microsoft.com/controls/vc/mfc42.cabThe Mfc42.cab file is provided and signed by Microsoft. The versions and files contained within follow what is listed in the .inf file above:
[msvcrt.dll] - FileVersion=4,20,0,6164 [mfc42.dll] - FileVersion=4,2,0,6256 [olepro32.dll] - FileVersion=4,2,0,6068A signed cab file for MFC 4.0 and 4.1 ActiveX Control dependencies will be provided at a later time and will be referenced in this article. It is not necessary to provide these files for controls running under IE 3.0. However, if you are running a browser other than Internet Explorer 3.0 that supports ActiveX Controls, you may need to provide these DLLs.
REFERENCES ActiveX SDK, Packaging component code for automatic download ActiveX SDK, Safety API Reference ActiveX SDK, Signing with Microsoft Authenticode(TM) Technology ActiveX SDK, Cabinet (.cab) File Technology: Data Compression and Disk Layout. |
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.