Compile the INF file when the ActiveX control is packaging the cab

Source: Internet
Author: User

Although Microsoft does not trust ActiveX more and more, many people prefer this technology. The editor of this blog seems to have used ActiveX.

After the OCX control is compiled, it can only be released after it is packaged into a cab file and added with a digital signature. If you are using vc6, the problem is simple, after packaging, you do not need to consider the control Runtime Library. The current XP system and the 2kpro to be eliminated already have such a Runtime Library. However, if you are using. net2005, you will encounter issues related to the Runtime Library. These problems can only be solved by the installation file. inf in the cab compressed package.

First look at the basic inf file format

[Version]
; Region settings
Signature = "$ Chicago $"
Advancedinf = 2.0

[Add. Code]
Which indicates the items in the installation package, which includes ActiveX. ocx, msvcr80.dll, mfc80u. dll, and msvcp80.dll.
Here, the same file name and item name are usually used for maintenance.
ActiveX. ocx = ActiveX. ocx
Msvcr80.dll = msvcr80.dll
Mfc80u. dll = mfc80u. dll
Msvcp80.dll = msvcp80.dll

[ActiveX. ocx]
This is the ActiveX control file.
File-win32-x86 = thiscab
; Indicates that the file is needed in the current installation package, the file-win32-x86 indicates that the file is a file under Win32 System
CLSID = {A3B4C60F-24A7-40E8-A06B-1A5EFE5F0A43}
The GUID value of the installation package is generated by the system when the project is created. It is generally stored in the IDL file named after the project name, And the guid of the project class information is used.
Registerserver = Yes
; Indicates that this control needs to be registered,
Generally, only the written files need to be registered. The Runtime library files and the DLL files that may exist in the system do not need to be registered, such as mfc70.dll.
Fileversion =
The version of this file, which must be separated by commas

[Msvcr80.dll]
This is the first dependency file of the OCX control. In some cases, it indicates that the dependency file must be installed in the order of dependency. You can use the rule "Install first for all remaining DLL dependent Files, however, I did not see any specific instructions on msdn, and I did not find any problems related to sequence in my own tests, in addition, OCX controls are written at the beginning in many places, but OCX files are most dependent on other files. It seems that writing in order is a bit superstitious"
Fileversion = 8, 00, 50727,42
Here is the version of the DLL file. Note that this version can be seen in the version tab of the file attribute, I don't know why the version number shown here is sometimes 0 more than the version number displayed on the outermost side. Note that after copying to the INF file, you must change the dot separator to a comma separator.
Hook = mfc80installer
The hook is a reserved word, indicating where the project is attached. If yes, it indicates that the project is attached to the target item. The hook is not a required item, this indicates that the file will be mounted to the mfc80installer

[Mfc80u. dll]
Fileversion = 8, 00, 50727,42
Hook = mfc80installer
 
[Msvcp80.dll]
Fileversion = 8, 00, 50727,42
Hook = mfc80installer
; The above two items are the same as those in [msvcr80.dll], and will not be explained here

[Mfc80installer]
; Mounting item
File-win32-x86 = http: // 192.168.1.117/helloactivex/mfc80.cab
The location of the mounted file is in an address.
Runner1_extract_dir1_vcredist_x86.exe
Download the vcredist_x86.exe file in the package downloaded from this address. % extract_dir % indicates the decompressed directory after the download.

It is not mentioned above, that is, "Why is this hook ?", Many INF files are written in this way.

[Add. Code]
Msvcr80.dll = msvcr80.dll
Mfc80u. dll = mfc80u. dll
Msvcp80.dll = msvcp80.dll
ActiveX. ocx = ActiveX. ocx


[Msvcr80.dll]
File-win32-x86 = thiscab
; The file is in the current installation package
Fileversion = 8, 00, 50727,42
Registerserver = No
; No need to register
Destdir = 11
; The file will be installed under system32 in the directory where the system is located

;........

I used this method to test 2kpro and XP without installing any software. The installation fails because the Runtime Library does not match, if your control is developed using MFC of vs2005, you cannot use this method to convert msvcr80.dll and mfc80u. DLL, msvcp80.dll, these controls depend on files installed to the target location, I do not understand the specific reason.

The hook here is to solve the problem mentioned above: to install a runtime environment for the machine that is installed with the control. Many people may see that limit 6.0 is over, and there is an error in his main example.

[Mfc42installer]
File-win32-x86 = value = http://activex.microsoft.com/controls/vc/mfc42.cab

The above "value =" is unnecessary. If this content is added, the installation package cannot be downloaded.

After the attached hook value is included in the dependent file DLL, the installation file will go to the hook location to find the file to be downloaded and installed, here I will add the/Microsoft Visual Studio 8/SDK/V2.0/bootstrapper/packages/vcredist_x86/packages file, without any other files.

Pack the mfc8 Runtime Library according to the above method and hook the DLL and Runtime library files.

The above content has passed the beta test on XP and 2 k pro without any software installed. By the way, ActiveX controls can be run as long as they are run in the tool tested by controls, if the environment problem occurs on the target machine, INF is the only way to solve the environment problem.

The last note is that the release version is released. If the debug version is used, two library files "mfc80d. dll" and "msvcr80d. dll" will be missing"

 

This blog reposted by csdn usersHttp://blog.csdn.net/immc1979/archive/2007/04/20/1572222.aspxI think it is very practical. I will summarize it from my practical experience and learn from it. Thanks to immc1979.

 

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.