Use a cab package to deploy ActiveX Controls

Source: Internet
Author: User

This is the most common way to deploy ActiveX controls. Choose msdn> Vsiual studio> visual c ++> reference> library reference> MFC> concepts> MFC Internet programming task> creating signed cab files for MFC-> creating a cab file is described in detail.

To put it simply, download the cabsdk with tools such as cabarc, create the INF file, and then use cabarc to create the cab file. Finally, sign the cab.

1. You can download the cabsdk from msdn.

2. The parameters and structure of the INF file can be found in msdn-> Web development-> Internet Explorer development-> content extenstions-> content and component delivery-> Internet component download-> overviews/tutorials-> about inf file architecture and using INF files are described in detail.

The trouble is that the target location in INF can only be % WINDIR % or % WINDIR %/system. It cannot be other directories, and adding other operations is also relatively complicated.

Fortunately, there is a setup hooks mechanism that can insert execution commands. You can execute any command, including bat, so that you can write all the installation operations as BAT. The disadvantage is that a black DOS window pops up during installation and cannot be hidden. So I simply wrote a Windows applet, which does not display my own windows, and opens a process execution BAT file in the background based on the input parameters. The configuration is as follows:
[Version]
Signature = "$ Chicago $"
Advancedinf = 2.0

[Setup hooks]
Hook1 = hook1
[Hook1]
Run = % extract_dir %/shell.exe % extract_dir %/setup. Bat % extract_dir %

Export extract_dir is the cab decompression directory, and shell.exe is the background process startup shell of the hidden form I wrote. Setup. bat is the script for installing the control. To allow the script to obtain the decompressed directory, pass % extract_dir % as the parameter. You can perform various general operations in the script. This command can be used for debugging.
Run = % extract_dir %/shell.exe % extract_dir %/setup. Bat % extract_dir %> C:/debug.txt

 

3. Run the cabarc command to create the cab file and signature. I like to use batch processing commands because there are many files in the cab and it is inconvenient to write them in the batch processing commands. Therefore, I usually write the files to be packaged into filelist, and then write the Packaging Commands to process files in batches. For example

Build. BAT for packaging and Batch Processing
Set Path = E:/mssdk/mscabsdk/bin; % PATH %
Cabarc n release/MSF. Cab @cabfilelist.txt
Signcode-V view. PVK-SPC view. SPC release/SEL. Cab

Cabfilelist.txt directly lists the files to be packaged, one row per file. Package the dependent library file, insert file, installation script, and execute external shell shell.exe. This is the file of one of my projects:
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.crt/Microsoft. vc90.crt. manifest
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.crt/msvcm90.dll
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.crt/msvcp90.dll
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.crt/msvcr90.dll
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.mfc/Microsoft. vc90.mfc. manifest
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.mfc/mfc90.dll
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.mfc/mfc90u. dll
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.mfc/mfcm90.dll
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.mfc/mfcm90u. dll
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.mfcloc/Microsoft. vc90.mfcloc. manifest
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.mfcloc/mfc90chs. dll
E:/microsoftvisualstudio9/VC/redist/x86/Microsoft. vc90.mfcloc/mfc90enu. dll
Sel. inf
Setup. bat
../Release/SEL. ocx
../Release/shell.exe

Controls without digital certificate signatures will be intercepted securely. Therefore, signature is necessary. The last step of packaging the script is signature. View. PVK and view. SPC are my own certificates. For more information about how to generate and install a certificate, see my article.

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.