Develop ActiveX program in vc6 and release full strategy (2 ))

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]

I,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.exePack 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.

III,The actvxdoc tool used 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:

(Figure 1: makecab package tool set)

2, Set system environment variables, right-click "my computer"ÀSelect "attribute"ÀSelect the "advanced" tab to open the system attribute area 2:

(Figure 2: System attribute section)

3In the system properties section, click "environment variables (N) "Button to open Figure 3:

(Figure 3: System variables)

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) ", Add"; e \ makecab ":

(Figure 4: Edit System variables)

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.

(Figure 5; OCX control path for Operation)

Iii. ActiveX publishing steps

1. Click Start"À"Dynamic line (R)"ÀEnter "cmd"ÀEnterÀGo to the directory where the control to be operated is located, as shown in 6:

(Figure 6: Go to the E: \ evs1300 directory)

 

2. CreatePVKFile(Private Key File), Enter"Makecert-SK evs1300 evs1300.pvk-N Cn =Xxxxxxx"And press Enter,7As shown in:

(Figure 7: CreatePVKFile)

3Create a CER file (company certificate), and enter"Makecert-SK evs1300.pvk evs1300.cer"And press Enter,8As shown in,Successed"Prompt, will be inE: \ evs1300Directory generationEvs1300.cerFile,9As shown in:

(Figure 8: Create a CER file)

(Figure 9: generating evs1300.cer)

4Create a SPC testing software publisher certificate and enter"Cert2spc evs1300.cer evs1300.spc"And press Enter,10As shown in:

(Figure 10: Create a SPC testing software publisher Certificate)

5Create 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

11, and save it as E: \ evs1300 \ evs1300.inf, 12

 

(Figure 11: evs1300.inf)

(Figure 12: Save evs1300.inf)

In the content of evs1300.inf, [Version] And [Add. Code] Items are required, [Add. Code] The number of key-value items depends on the number of items you have prepared below. [Msvcr71.dll] , [Mfc71.dll] , [Msvcp71.dll] That is, if you want Msvcr71.dll , Mfc71.dll , Msvcp71.dll The three items must be written in the release package. INF , And the specific content of these three items is fixed, you can copy the past. The most important thing is [Evs1300.ocx] Items, including CLSID And Fileversion Yes Evs1300.ocx Of Classid And Version This requirement must be met. Otherwise, we will release Cab The package cannot be automatically updated, downloaded, and installed on the client. How can we know this? Evs1300.ocx Inside Classid And Version What about it? 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:

(Figure 13: ActiveX encryption enter)

In Figure 13, click "File"À"Open ...", Open the OCX control you want to view, as shown in figure 14:

(Figure 14: Open the control)

After the control is opened, select <all interfaces = ""> </All> in the "class" drop-down box on the right side of the interface.FileversionAndClassid,15As shown in:

(Figure 15: control attributes)

6Create a cab file and enter"Cabarc-s 6144 n evs1300.cab msvcr71.dll mfc71.dll msvcp71.dll evs1300.ocx evs1300.inf"And press Enter,16As shown in:

(Figure 16: Create a cab file)

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

(Figure 17: Digital Signature wizard)

 

8, Click "next (N) ", As shown in Figure 18, select the file evs1300.cab that is digitally signed and has been made into a cab package.

 

(Figure 18: select a cab package)

 

9SelectCabAfter the package, click "next (N), And select "Custom (C) And click Next (N) "Button,19As shown in:

(Figure19: Select the signature type)

10Next, click "select from file (F) ", Select the createdEvs1300.cer,20As shown in:

(Figure20: SelectCERCertificate)

11In the Graph20Click "next (N) "Button to the graph21And then in the graph21Select"CSPPrivate Key (K)".

(Figure21: Select the location of the private key)

12In the Graph21Click "next (N), And then click22Hash inAlgorithmSelect"ShalAnd click "next (N.

(figure 22 : select the hash algorithm)

13 select the certificate path from" Certificate path "all certificates in, including the root certificate ( C )", in "other certificates (optional) select PKCS #7 certificate ( . p7b ) file certificate ( P ):", click Browse ( r ) ... select evs1300.spc file, click Next ( n , 23 :

(Figure23: Select another certificate)

14In the displayed "data description" window, enter the company name and website, and click "next (N) "Button,24As shown in:

(Figure24: Input data description)

15And now most of the work has been completed, in the next step is optional, its role is onlyCabAdd a timestamp. You can skip this step,25As shown in:(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

(Figure25: Timestamp for data)

16, Complete, in the figure25Click "next (N) "Button to go to the last step of the digital signature wizard, that is, the Operation overview,26As shown in, click the "finish" button to complete the process,27As shown in:

(Figure26, Complete operations)

(Figure27: Signature success prompt)

 

Download the cab Tool

From: http://huangzh.javaeye.com/blog/110834

 

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.