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 Intern.
Et, Intranet, and commercial applications. 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.
It adopts 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 = aaaaaaaaaaactivex.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 ).
References
[1] Pan aimin. COM principle and application [M]. Beijing: Tsinghua University Press, 1999.
[2]. Packaging ActiveX Controls. aaaaaaaaaasupport.microsoft.com, 2003.
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.