Create a CAB file for the ActiveX control

xiaoxiao2021-03-13  185

Add a CAB file for ActiveX space

purpose:

1. Depending on the MFC library or ATL library, the ActiveX control, which must be normal, must rely on these libraries. But you can't guarantee that your user's machine is equipped with the same library as you developed the environment, so when you release an ActiveX control, you have to include the existence of these dependencies.

2. The ActiveX control running on the network must ensure that your release is small enough to let users endure the download time, and of course, the smaller, better. The control itself will find it insignificant, but you have to consider the space he supported, you will find it with its support library, your control will change the bloated, so you have to find a way Your control is reduced to lose weight.

3. After getting the control, it is of course registered before use, but you don't forget, and his registration work of the relying on the library is waiting for your patient's REGSVR32.

Oh, God, users just want to browse a web page, but they want to do such trouble, who is willing to do, us will not care about these technical details, they want to lightly under the computer, do everything Normal, they want to automate! And all, CAB can help you completely solve it.

principle:

Backed into CAB compressed files by high compression techniques (30% higher than ZIP compression). When the user first browses the webpage where your control is located, it will automatically prompt the control download. After the download will find the corresponding DLL of your computer according to the * .inf text file in the CAB file (the control itself " OCX is a special DLL) whether to register, if not, will automatically register, and then the control can be used normally.

(Note: For CAB compression technology, please refer to MSDN or online search)

Create a CAB file:

1. Create an INF file.

The INF file is a text file to specify a file (such as a DLL file or other OCX file) that needs to be displayed or downloaded as the control. The INF file enables you to bundle all the required files in a compressed CAB file. By default, the version number is not downloaded with the same file as the existing file on the user's hard drive. More information about INF files and their options, including how to create an INF file-independent INF file, see the INF file and use INF files (in MSDN Library / Setup API) in the Platform SDK document (in MSDN Library / Setup API / SETUP API / Overview / setup applications directory).

For example, the following INF file is used to create a CAB file for the AxyourControl control. AxyourControl is developed by a library (MFC, ATL or other), assuming that he supports the main three DLL libraries mainly by Need1.dll, Need2.dll, Need3.DLL (specifically and the specific library files are reviewed by the MSDN) content).

; Sample Inf File for AxYourControl.ocx

[Version]

Signature = "$

China

$ "

Advancedinf = 2.0

[Add.code]

AxyourControl.ocx = AxyourControl.ocx

NEED1.DLL = Need1.dll

NEED2.DLL = Need2.dll

NEED3.DLL = need3.dll

Needed DLL [Need1.dll]

FILE-WIN32-X86 = thiscab

Fileversion = 2,00, 0,7024

Destdir = 11

RegisterServer = YES

Needed DLL

[Need2.dll]

FILE-WIN32-X86 = thiscab

Fileversion = 2,00, 0,7024

Destdir = 11

RegisterServer = YES

Needed DLL

[Need3.dll]

FILE-WIN32-X86 = thiscab

Fileversion = 2,00, 0,7024

Destdir = 11

RegisterServer = YES

[AxyourControl.ocx]

FILE-WIN32-X86 = thiscab

CLSID = {4cbbc676

-507F

-11D0-B98B-000000000000}

Fileversion = 1, 0, 0, 1

RegisterServer = YES

; END OF INF FILE

This INF file specifies that Need1.dll, Need2.dll, and NEED3.DLL need to be installed on the system. If these DLLs have not yet exhibited in the system, it will be downloaded from the CAB file created with this INF. "Thiscab" is a keyword indicating that the CAB contains this INF. You can also download the desired DLL from an HTTP location by specifying an absolute or relative path, for example:

File-win32-x86 = http: //example.microsoft.com/mydir/needed.dll

Keyword "File-Win32-X

86 "

The platform is identified as X86 specific.

You can get the version number of the file by clicking the mouse button on the file in the Windows Explorer. Select "Properties" from the list of display, then select the "Version" tab in the displayed dialog. Sometimes you need to insert an additional 0 in the file version. For example, the version number of the ATL.DLL in the dialog is shown to 2.00.7024. In the INF file, this becomes 2, 00, 0, 7024.

"DestDir" is where the directory to load files is located: 11 Specify the system directory as Windows / System or Winnt / System32; 10 Specify a Windows Directory, Windows or Winnt. If no Destdir is specified, the code is installed in a fixed OCCChe directory.

"CLSID" is the CLSID of the control to be installed.

2. Run the Cabarc utility.

Cabarc.exe is a CAB file making tool for Microsoft. You can download the Cabin SDK Toolkit to Microsoft's official website. After downloading, unzip the installation, which can be found in a bin directory in its directory.

Cabarc should be run in a directory containing the source file. On the command line, press the source file in the order in INF, and place the INF file in the last. For example, if you want to generate a CAB file of the AxyourControl control from the INF file above, use the following command:

... / BIN / CABARC -S 6144 n AxyourControl.cab need1.dll Need2.dll Need3.dll AxyourControl.ocx AxyourControl.inf

The -s option retains space for code signatures in the compressed file. n Commands Specify that you want to create a CAB file. For a list of Cabarc commands and options, type only Cabarc on the command line:

... / BIN / CABARC

Some other supplements:

1. The DLL files you need to include MSVCRT.DLL, MFC42.DLL and OLEPRO32.DLL, where mfc42.dll will definitely develop controls in the VC7 environment, so you should be MFC71 . 2. An important topic for creating a CAB file for ActiveX space is to pack it as a signature compression (CAB) file. The signature file allows users to rest assured that the code security control is downloaded. Regarding this topic, you need to apply for a certificate. For details, please refer to MSDN:

MS-help: //ms.msdnqtr.2003feb.2052/vcore/html/creating_signed_cab_files_for_mfc_and_atl_controls.htm

3. Regarding the version of the DLL when INF, you can click on his property dialog box. You can see it, pay attention, pay, " .

转载请注明原文地址:https://www.9cbs.com/read-129185.html

New Post(0)