The ActiveX control is packaged into a cab and placed on the webpage for automatic download and installation.

Source: Internet
Author: User

[Background]
Anyone who has done ActiveX Control knows that if you want to use the ActiveX control function on your webpage, you must register it locally on the client, that is to say, the user must first put the ActiveX control (test. OCX) Put it under % System %/system32 on the local machine, and then run regsvr32 test in the DOS tool. OCX command for registration. However, if you do this, it means you are in danger, because you achieve your goal by letting users deploy and set the environment on their own, this will lose the value of the software project itself. How can we solve this problem? Smart, you will soon think that we can enable users to automatically download and install the ActiveX control on the client, so that we can implement the functions we want, you do not need to deploy and set the environment on your own.
[Prerequisites]
1. tool set for packaging ActiveX controls and adding data identification names:
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.
II. The OCX control evs1300.ocx used for packaging.
3. Use actvxdoc to view the OCX control.
[Production process]
I. Environment Settings
1. Download The makecab package and decompress it to the local directory (such as the root directory of the E disk). If you view the tool set shown in 1, the download is successful:

2. Set system environment variables, right-click "my computer", select "properties", and select the "advanced" tab. The system attribute area shown in 2 is displayed:

3. Click "environment variables (N) "Button to open Figure 3:

4. Select "system variables (S(W) To open the "Edit System variables" dialog box, as shown in 4, and then in the "variable value (V) "To add"; E/makecab ":

2. Place the OCX control for packaging in the root directory of the E disk (this document uses the evs1300.ocx Control for introduction), as shown in Figure 5. evs1300.ocx is the control object for operations in this document, the mfc71.dll, msvcp71.dll, and msvcr71.dll files are usually packaged together, but they are not required (recommended for packaging together) and can be found in the System32 directory of the system, please prepare yourself.

Iii. ActiveX publishing steps

1. Click Start. Press enter to enter the directory of the control to be operated, as shown in Figure 6:

2. Create a PVK file (private key file), input "makecert-SK evs1300 evs1300.pvk-N Cn = xxxxxxx company" in the command line, and press enter, as shown in 7:

3. Create a CER file (company certificate), enter "makecert-SK evs1300.pvk evs1300.cer" in the command line, and press enter, as shown in 8. If the "successed" prompt appears, the evs1300.cer file is generated in the E:/evs1300 directory, as shown in 9:

4. Create a SPC testing software publisher certificate, enter "cert2spc evs1300.cer evs1300.spc" in the command line, and press enter, as shown in 10:

5. Create an INF file and use the record book to edit the following information.

    1. [Version]
    2. Signature = "$ China $"
    3. Advancedinf = 1.0
    4. [Add. Code]
    5. Evs1300.ocx = evs1300.ocx
    6. Msvcr71.dll = msvcr71.dll
    7. Mfc71.dll = mfc71.dll
    8. Msvcp71.dll = msvcp71.dll
    9. [Evs1300.ocx]
    10. File = thiscab
    11. CLSID = {0440906e-9bd6-4f3e-b65a-39e1b339d9da}
    12. Fileversion = 1, 0, 0
    13. Registerserver = Yes
    14. [Msvcr71.dll]
    15. File-win32-x86 = thiscab
    16. Registerserver = No
    17. Destdir = 11
    18. Fileversion = 7,10, 3052, 4
    19. [Mfc71.dll]
    20. File-win32-x86 = thiscab
    21. Registerserver = No
    22. Destdir = 11
    23. Fileversion = 7,10, 3077,0
    24. [Msvcp71.dll]
    25. File-win32-x86 = thiscab
    26. Registerserver = No
    27. Destdir = 11
    28. Fileversion = 7,10, 3077,0

In the content of evs1300.inf, the [version] and [Add. Code] items are required. The value of the [Add. Code] key depends on the number of items you have prepared below. [Msvcr71.dll], [mfc71.dll], and [msvcp71.dll] are not mandatory. If you want to include msvcr71.dll, mfc71.dll, and msvcp71.dll in the release package, then these three items must be written in INF, and the specific content of these three items is fixed. You can copy them. The most important thing is the [evs1300.ocx] item. CLSID and fileversion are the classid and version of evs1300.ocx, no, the released cab package cannot be automatically updated, downloaded, and installed on the client. Speaking of this, how can we know the classid and version in evs1300.ocx? In the preceding prerequisites, I introduced actvxdoc, a tool used to view the OCX control. You can use it to double-click the file and run it. The interface shown in Figure 13 is displayed:

On the page in Figure 13, click "file" à "Open ...", Open the OCX control you want to view, as shown in figure 14:

After the control is opened, select "" in the "class" drop-down box on the right side of the interface to see the fileversion and classid we want to find, as shown in Figure 15:

6. Create a cab file, enter "cabarc-s 6144 n evs1300.cab msvcr71.dll mfc71.dll msvcp71.dll evs1300.ocx evs1300.inf" in the command line, and press enter, as shown in 16:

7. Use code signing wizardto sign a cabin. First, double-click signcode.exe in the tool set (or enter "signcode" in the command line and press Enter). The digital signature wizard shown in Figure 17 is displayed:

8. Click "next (n)" and go to Figure 18. Select the file evs1300.cab that has been made into a cab package to be digitally signed.

9. Select the cab package, click "next (n)", select "Custom (c)" from the selected signature type, and click "next (n) "button, as shown in 19:

10. Click the select from file (f) button and select the created evs1300.cer, as shown in 20:

11. Click "next (n)" in Figure 20 to go to Figure 21, and then select "Key (k) in CSP" in Figure 21 )".

12. Click "next (n)" In Figure 21, and then hash in Figure 22AlgorithmSelect "shal" and click "next (n.

13. In "Certificate in certificate path", select "all certificates in certificate path, including root certificate (c)". (optional) select "included in the following PKCS #7 certificates (. p7b) file certificate (P): ", and click" browse (r )..." Select the evs1300.spc file, and then click "next (n)", as shown in 23:

14. Enter the company name and website in the pop-up "data description" window, and click "next (n)", as shown in Figure 24:

15. Now most of the work has been completed. In the next step, it is an optional operation. The function is to add a timestamp to the cab. This step can be skipped, as shown in Figure 25:

(Here I will provide three freeCodeSignature timestamp address)

Verisign: http://timestamp.verisign.com/scripts/timstamp.dll

Comodo: http://timestamp.comodoca.com/authenticode

Geotrust/trustcenter: http://www.trustcenter.de/codesigning/timestamp

16. Complete. Click "next (n)" in Figure 25 to go to the last step of the digital signature wizard, Which is Operation overview, 26, click the "finish" button to complete the process, as shown in Figure 27:

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.