Web Publishing of ActiveX Controls

Source: Internet
Author: User
Tags ole

Web Publishing of ActiveX controls consists of two parts:

1. ActiveX control production requirements
The coding of ActiveX controls generated by web publishing requires that the security interface "IObjectSafety interface" of ActiveX controls be implemented ":

 

2. ActiveX control release requirements

1) create a cab package for ActiveX space:

To create a cab file, see
Create a signature cab file for the MFC and ATL controls. This section describes how to create a cab file for distributing the 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 remove
Signature = "$ Chicago $"
Advancedinf = 2.0

[Add. Code]
Polygon. dll = polygon. dll
ATL. dll = ATL. dll

; Needed DLL
[ATL. dll]
File-win32-x86 = thiscab
Fileversion =
Destdir = 11
Registerserver = Yes

[Polygon. dll]
File-win32-x86 = thiscab
CLSID = {4cbbc676-507f-11d0-b98b-000000000000}
Fileversion =
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 Code Install it 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.
The-s option retains the space used for code signature in the compressed file. N command to create a cab file. For a list of cabarc commands and options, type only cabarc on the command line:
C:/mssdk/bin/cabarc

 

 

 

 

 

Analysis of ActiveX Control cab Compression

Ren FengHua


Abstract This article briefly introduces how to compress a cab and use wincab to compress an ActiveX control into a cab file.
Key words ActiveX control; cab compression; wincab; INF file

1. Introduction
ActiveX control technology is developed on the basis of OLE. It extends OLE to adapt to Internet, Intranet, and commercial applications. Program . When the ActiveX control program code is uploaded and transmitted over the Internet, it makes sense to use the compression technology to transmit the program code.
On the other hand, if the ActiveX control is also called to other DLL program modules, ie must also download these programs to the local device. Microsoft adopts the common cab compression method to store ActiveX control applications and other related files in the same cab file, then, specify the URL path of the cab file in the codebase attribute. When ie finds the codebase attribute, it automatically parses the URL address to decompress the cab file to the temporary directory of the client, registers the relevant file, and calls the com api function to create the ActiveX control object. This completes the transmission of ActiveX controls.

2. Overview of cab compression technology
Microsoft is releasing Windows 95 and plus! 95 and other software use a new form of cab compressed package, which has the advantages of high compression rate, good security, and is not easy to be damaged, and is very popular among users and software manufacturers. Many users even want to compress and back up their data files in the form of a cab compressed package to minimize the disk space occupied by the backup files and improve their security. Currently, the software used to create CAB files mainly includes cabarc and wincab.
Cabarc is a tool used to compress, list files in a compressed package, and decompress the CAB files. Cabarc supports wildcard and recursive path search. However, cabarc uses a command line interface similar to common compression tools,
In addition, there are many parameters, which are not in coordination with mainstream Windows operating systems and are not very convenient to use.
Wincab is a new visual software for creating cab compressed packages. It has a graphical interface, supports volume compression, and can be used to create a cab compressed package (*. EXE file format) and other excellent functions, which fundamentally solves the problem of creating the cab compressed package. When running wincab.exe, make sure that the makecab.exe file is in the same directory.
This article takes wincab as an example to introduce how to create a cab file of ActiveX control.

3. Compress ActiveX controls into cab files
The main steps are as follows:
1) register the yourctl. ocx control.
2) Create the yourctl. inf file.
The inf file format is as follows: (When Visual C ++ 6.0 is used)
[Version]
Signature = "$ Chicago $"
Advancedinf = 2.0
[Add. Code]
Yourctl. ocx = yourctl. ocx
Mfc42.dll = mfc42.dll
Msvcrt. dll = msvcrt. dll
Olepro32.dll = olepro32.dll
[Yourctl. ocx]
File-win32-x86 = thiscab
CLSID = {yourctl. ocx CLSID} // you can find it in the yourctl. odl file.
Fileversion =
Registerserver = Yes
[Msvcrt. dll]
Fileversion = 6, 0, 8168, 0
Hook = mfc42installer
[Mfc42.dll]
Fileversion = 6, 0, 8168, 0
Hook = mfc42installer
[Olepro32.dll]
Fileversion = 5, 0, limit 1, 0
Hook = mfc42installer
[Mfc42installer]
File-win32-x86 = value = http://activex.microsoft.com/controls/vc/mfc42.cab
Run = % extract_dir %/mfc42.exe

It should be noted that the fileversion of msvcrt. dll, mfc42.dll, and olepro32.dll varies according to different VC versions. For example, in vc5.0sp3, it should be as follows:
Olepro32.dll 5, 0, 4230,1
Mfc42.dll, 21
Msvcrt. dll 5, 0
Each VC version has a different version number. Here we only introduce the two common versions. In addition, the download path of mfc42installer except for vc4.1 and earlier versions.
3) Start wincab and start compression. (In this example, "makecab.exe" must be in the wincab directory)
(I) Start wincab, run the "new" command in the "cabinet" menu, or click the "new cabinet" button on the shortcut toolbar to prepare a new cab compressed package.
Ii) Click "add file (s) to Cabinet" on the shortcut toolbar to open the "add file (s) to Cabinet" dialog box.
Iii) Select the files to be added to the cab package and click the OPEN button to add them to the wincab file list. Here, you only need to add the yourctl. ocx and yourctl. INF files.
Iv) in the "Cabinet path and name" box on the wincab shortcut toolbar, enter or use the "browse for path and name" button to specify the path and file name of the cab package.
V) specify the size of the cab package in the "cabinet size" column.
Vi) in the compression method box, select the appropriate compression method.
Vii) Click the Save cabinet button, and wincab compresses data according to user requirements.
Viii) after compression, wincab will provide a "wincab Report" report box to report the number of files, size of files before and after compression, compression ratio, and compression time. So far, a cab file is generated.
4. Conclusion
Since the cab compression rate is much higher than the commonly used ARJ, zip, rar, and other compressed packages (about 20%), this further reduces the disk space occupied by compressed files, when ActiveX controls are transmitted over the Internet, network traffic is reduced and web pages are opened faster.
In addition, because the cab compressed package has the "read-only" attribute, it cannot be modified or deleted after being created. Therefore, it is not susceptible to problems such as viruses and misoperations, security is also guaranteed, which is the best choice for users to compress and Back Up Files in windows.
Note: ** Fund project **, National 973 Plan (No.: g1998030600 ).
About the certificate and signature-| zuiwanting published on 9:58:00

Tools related to certificates and signatures under/program files/Microsoft Visual Studio. NET 2003/SDK/V1.1/bin
1. Makecert.exe --- certificate creation tool
2. Cert2spc.exe --- issuer Certificate Test Tool
3. Signcode.exe --- file signature Tool
Create your own root certificate:
Makecert-SK mypk-SS myname-n "cn = luo31 Studio"-r c:/luo31.cer
SK-indicates the key container location of the topic, the certificate storage name of the SS-topic, the N-certificate issuing object, and the R-certificate storage location;
If you need to export the private key file, do not use SK, instead of S, eg: makecert-SS myname-n "cn = luo31 Studio"-sv c: /luo31.pvk-r c:/luo31.cer
Create a subcertificate authorized by the root certificate:
Makecert-SK "mypk"-Is myname-n "cn = luo31"-$ commercial-ic c:/luo31.cer C:/31.cer
SK-indicates the key container location of the topic, is-issuer's certificate storage name, N-certificate issuing object, and IC-issuer's certificate storage location, -$-Authorization scope (used for code signature );
Use cert2spc to generate a SPC issuer certificate (optional ):
Cert2spc C:/31.cer C:/31.spc
Use signcode to sign your program, library, or cab package:
Double-click signcode or type signcode in the console. The signature wizard is started without parameters. Select "custom options" in step 3, select "select from file" in Step 4, and select 31. for SPC or 31.cer, select "Private Key in CSP" in step 5, and select the mypk defined in the key container. For other steps, the default value is. If you want to add a timestamp, on the timestamp server address, type: (Free timestamp authentication) http://timestamp.verisign.com/scripts/timstamp.dll;
After that, observe the file attributes you have signed and add a digital signature item.

3. Reference of ActiveX Control on the page

codebase =" graphocx. cab # version =, "classid =" CLSID: 87186ea1-4d89-4f3e-9d25-1f03f0dddb95 "
name =" axgraphocxscada "viewastext>




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.