ActiveX control is packaged into a cab for automatic download and installation in the browser

Source: Internet
Author: User

Preface

We use some of our OCX or DLL files in the browser. on x86 machines, we need to manually copy these files to the Windows/system32 folder, then run the doscommand regsvr32 test. OCX registration before use.
We have been using the installation package, that is, the client needs to install an EXE installation package provided by us. The purpose of this EXE installation package is to package a bunch of files such as OCX and DLL, during Client installation, copy all these files to the Windows/system32 folder, and run the doscommand regsvr32 test. OCX registration file. However, if we use this method, there will be a defect, that is, the browser must install the EXE installation package we provide before using the system, otherwise it will not be possible.

Introduction

Microsoft defines according to the definition of Microsoft's authoritative Software Development Guide msdn (Microsoft Developer Network), ActiveX plug-ins are also called Ole controls or OCX controls, which are some software components or objects, you can insert it into a web page or other applications.Program.

All the friends who have done ActiveX Control know that the browser can automatically download the ActiveX control to Windows/system32 and register it. In this way, we do not need to manually copy files, install any EXE installation package, and implement the functions we want.

Preparations

To automatically download ActiveX control, you need to package the file into a cab file, download the cab file in the browser, and decompress it.

(1) We need to prepare the following files:

Tool Set for packaging ActiveX controls and adding data identification names. 1:
Makecert.exe creates a certificate in cer format, that is, an X.509 Certificate. You can also create a private key and a public key.
Cert2spc.exe converts a CER certificate to a SPC certificate, that is, a PKCS #7 certificate.
Cabarc.exe packs OCX into a cab.
Signcode.exe signs the certificate to OCX.
Chktrust.exe check whether the OCX after signing the certificate is correct.
Certmgr.exe is used to manage certificates.
Actvxdoc.exe is a tool used to view OCX controls.

 

(Figure 1)

(2) OCX control XXXX. ocx used for packaging.

(3) xxxx. inf used to register the OCX control.

(4) files referenced by OCX files, such as XXXX. dll, xxxx. LIC, and XXXX. ico. 2.

 

(Figure 2)

Procedure

Now we are going to create a cab file ~~~

 

  • We first put all the files under the E: \ browseocx directory, 3.

    (Figure 3)

  • Choose Start> RUN> cmd to enter the directory of the control to be operated, as shown in figure 4.

    (Figure 4)

  • Create a PVK file (private key file) and enter"Makecert-SK browseocx. PVK-N Cn = XXXXXXXXAnd press enter, as shown in Figure 5.

    (Figure 5)

    Create a CER file (company certificate) and enter"Makecert-SK browseocx. PVK browseocx. Cer", Then press enter, as shown in 6. If the" successed "prompt appears

    The browseocx. Cer file is generated in the E: \ browseocx directory, as shown in 7.

    (Figure 6)

    (Figure 7)

  • Create a SPC test software publisher certificate and enter"Cert2spc browseocx. Cer browseocx. SPC", Press enter, as shown in figure 8. If the" successed "prompt appears,
  • The browseocx. SPC file is generated in the E: \ browseocx directory, as shown in figure 9.
  • (Figure 8)

    (Figure 9)

  • Create an INF file and use the record book to edit the following information:
  • [Version]

    Signature = "$ Chicago $"

    Advancedinf = 2.0

    [Add. Code]

    Gdiplus. dll = gdiplus. dll

    Mfc100.dll = mfc100.dll

    Msvcp100.dll = msvcp100.dll

    Msvcr100.dll = msvcr100.dll

    Acemfcd. dll = acemfcd. dll

    Goldenclient. dll = goldenclient. dll

    Goldenobjects. dll = goldenobjects. dll

    Piapi32.dll = piapi32.dll

    Rtdbbridge. dll = rtdbbridge. dll

    Browseocx. ocx = browseocx. ocx

    Browseocx. Lic = browseocx. Lic

    Browseocx. ICO = browseocx. ICO

    [Gdiplus. dll]

    File-win32-x86 = thiscab

    Registerserver = Yes

    Destdir = 11

    Fileversion = 6, 0, 3260,0

    [Mfc100.dll]

    File-win32-x86 = thiscab

    Registerserver = Yes

    Destdir = 11

    Fileversion =, 1

    [Msvcp100.dll]

    File-win32-x86 = thiscab

    Registerserver = Yes

    Destdir = 11

    Fileversion =, 1

    [Msvcr100.dll]

    File-win32-x86 = thiscab

    Registerserver = Yes

    Destdir = 11

    Fileversion =, 1

    [Acemfcd. dll]

    File-win32-x86 = thiscab

    Registerserver = Yes

    Destdir = 11

    Fileversion = 5, 4, 1, 0

    [Goldenclient. dll]

    File-win32-x86 = thiscab

    Registerserver = Yes

    Destdir = 11

    Fileversion = 1, 0, 3, 11

    [Goldenobjects. dll]

    File-win32-x86 = thiscab

    Registerserver = Yes

    Destdir = 11

    Fileversion = 1, 0, 3, 11

    [Piapi32.dll]

    File-win32-x86 = thiscab

    Registerserver = Yes

    Destdir = 11

    Fileversion =

    [Rtdbbridge. dll]

    File-win32-x86 = thiscab

    Registerserver = Yes

    Destdir = 11

    Fileversion = 1, 0, 0

    [Browseocx. ocx]

    File-win32-x86 = thiscab

    CLSID = {F6157CB2-D9CD-4780-B3BF-C1EF13D48446}

    Registerserver = Yes

    Destdir = 11

    Fileversion = 2, 0, 1, 0

    [Browseocx. Lic]

    File-win32-x86 = thiscab

    Registerserver = No

    Destdir = 11

    [Browseocx. ICO]

    File-win32-x86 = thiscab

    Registerserver = No

    Destdir = 11

    (Figure 10)

(Figure 11)

In browseocx. in the INF content, [version] and [add. code] is required, [add. the number of key-value items depends on the number of items you have prepared below.

[Mfc100.dll] and [msvcp100.dll] are the items I mentioned above that are not required. If you want to include mfc100.dll and msvcp100.dll in the release package, these two items are required.

It must be written in INF, and the specific content of these three items is fixed. You can copy them. The most critical is the [browseocx. ocx] item, where CLSID and fileversion are

It is the classid and version of browseocx. ocx. This requirement must be met. Otherwise, we cannot automatically update, download, and install the cab package on the client. Here, we are like

How can we know the classid and version in browseocx. ocx? In the preceding prerequisites, I introduced actvxdoc, a tool used to view the OCX control.

It. We double-click the file to run it. It may not run in win7.

 

Create a cab file and enter"Cabarc-s 6144 n browseocx. Cab gdiplus. dll mfc100.dll msvcp100.dll msvcr100.d

Ll acemfcd. dll goldenclient. dll goldenobjects. dll piapi32.dll rtdbbridge. dll browseocx. Lic browseocx. ICO browseoc

X. ocx browseocx. infAnd press enter, as shown in 12:

(Figure 12)

Use the code signing wizardto sign a cabin. First, double-click the signcode.exe in the tool set (or directly enter "signcode" in the command line and then return

The digital signature wizard shown in Figure 13 is displayed:

(Figure 13)

Click "next (n)". As shown in figure 14, select the file browseocx. Cab that has been made into a cab package to be digitally signed.

(Figure 14)

After selecting the cab package, click "next (n)", select "Custom (c)" from the selected signature type, and click "next (n)", as shown in figure

Figure 15.

(Figure 15)

Next, click the select from file (f) button and select the created browseocx. CER, as shown in 16:

(Figure 16)

Click "next (n)" In Figure 16 to go to Figure 17. Then, select "key in CSP" in figure 17 )"

(Figure 17)

Click "next (n)" In Figure 17, and then hash in Figure 18.AlgorithmSelect "shal" and click "next (n )".

(Figure 18)

In certificate path, select all certificates in certificate path, including root certificate (C), and select include

Under PKCS #7 certificate (. p7b) file certificate (P): ", and click" Browse (r )..." Select the browseocx. SPC file.

Click "next (n)", as shown in Figure 19:

(Figure 19)

In the displayed "data description" window, enter the company name and website, and click "next (n )".

Must be consistent with the previous description of PVK in the third part)

(Figure 20)

Now most of the work has been completed. In the next step, it is an optional operation. It only serves to add a timestamp to the cab. This step can not be done at all, as shown in figure

Figure 21:

(Figure 21)

Complete

(Figure 22)

At this time, we have made the cab package.

Add the object tag to the HTML file on the server:

The ActiveX control may be disabled in the browser sometimes. We need to set browser options.

Note: Open IE browser tool Internet option security custom level enable all ActiveX Controls

For example:

<Object ID = "chart" codebase = "./download/cfxieax. Cab # version =," type = "application/X-oleobject" Heigh

T = "910" width = "1870" classid ="CLSID: 21f49842-bfa9-11d2-a89c-00108b62bdda"Viewastext>

<Param name = "License" value = "./license/cfxie. Lic"/>

</Object>

 

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.