共用方式為


Embedding a Signed CAB File on a Web Page

ATL and MFC controls are embedded in Web pages using the <OBJECT> tag. Within the <OBJECT> tag, you need to specify three attributes for the control:

  • ID   The name of the control

  • CLASSID   The CLSID of the control

  • CODEBASE   The location from which to download the control. Note that CODEBASE can point at a number of different file types successfully.

As an example, the following Web page displays the ATL Polygon control archived in the CAB file created in the section on Creating an INF File. The address http://example.microsoft.com/mydir/polygon.cab should be replaced with the actual HTTP address of the CAB file:

<HTML>
<HEAD>
<TITLE>ATL 2.0 test page for object PolyCtl</TITLE>
</HEAD>
<BODY>
<OBJECT ID="PolyCtl" 
CLASSID="CLSID:4CBBC676-507F-11D0-B98B-000000000000"
CODEBASE="http://example.microsoft.com/mydir/polygon.cab">
</OBJECT>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub PolyCtl_ClickIn(x, y)
PolyCtl.Sides = PolyCtl.Sides + 1
End Sub
Sub PolyCtl_ClickOut(x, y)
PolyCtl.Sides = PolyCtl.Sides - 1
End Sub
-->
</SCRIPT>
</BODY>
</HTML>

CODEBASE can point directly to an OCX or DLL file:

CODEBASE="http://example.microsoft.com/mydir/polygon.dll#version=1,0,0,1"

Since this causes only the DLL or OCX file to be downloaded and installed, any necessary supporting DLLs must already be on the client machine.

If you include the optional version number with a CAB file, the version number should refer to the control being downloaded. For example, since POLYGON.DLL has a version number of 1, 0, 0, 1, the version for the CAB is also 1, 0, 0, 1:

CODEBASE="http://example.microsoft.com/mydir/polygon.cab#version=1,0,0,1"

If you do not include the version number, older versions of the same control will not be replaced if they are found on the client machine.

See Also

Concepts

Creating Signed CAB Files for MFC and ATL Controls