How to publish ActiveX Using DLL?

Source: Internet
Author: User

How to publish ActiveX Using DLL?

An ActiveX embedded in a Web page must call two DLL files. After I compress them into a cab file, they cannot be registered on the client. But the OCX itself is good. If you copy the OCX and two DLL files to the client, and then manually register the files, it will be okay.
 
So how to publish ActiveX Using DLL?
---------------------------------------------------------------
 
ZT:
 
1. If you need to create a cab file, you must first install cabarc or makecab with the cabinet SDK. The Cabinet SDK is http://msdn.microsoft.com/workshop/management/cab/cabdl.asp.
Cabarc can create, view, or work out files in the cab, while makecab can only be used to create the cab file.
2. When creating a cab file, you must include all the relevant files. You can use depends (included in VC) to check the required files. Use the INF file to write these items.
3. inf method: The inf file describes all OCX and DLL files in the cab. inf provides the required information through some naming regions.
 
How to Write INF
Generally, it is in the [version] area at the beginning:
Eg: [version]
Signature = "$ XXXX $"
Advancedinf = 2.0
Next is the most important [Add. Code] area:
Eg: [Add. Code]
Ctrl1.dll = c1section
Ctrl2.dll = ctrl2.dll
The above is the file name to be downloaded, followed by the region name corresponding to the file, which can be any name, but it is generally the same as the file name, so it is easy to maintain. Note that files in the [Add. Code] area should be sorted by dependencies. For example, if ctrl1.dll is dependent on ctrl2.dll, ctrl2.dll must appear before ctrl1.dll. Because the installation is performed in the opposite order, that is to say, you must first install ctrl2.dll, then ctrl1.dll and zookeeper. Remember clearly and do not reverse it.
Next is the area of each file.
[Ctrl1.dll]
File-win32-x86 = thiscab
Registerserver = Yes
CLSID = {.....}
Destdir =
Fileversion = 1, 0, 0
The first file value in the [ctrl1.dll] area tells ie where to get the DLL. The file consists of three parts, the first part is file, this is always the case (at least for the moment); the second part tells the declared supported OS that Win32 indicates windows, Mac is the Apple Mac ox, and the third part is the CPU type, for example, x86, PPC (Power PC), MIPS, or alpha.
The file value can be set to three URLs, ignore, and thiscab. If it is a URL, it indicates the location of the URL. If it is ignore, it indicates the OS and CPU, you do not need to download this file (ctrl1.dll); if it is thiscab, it is obviously in the current cab file.
The following is the registerserver. You can obtain two values: Yes and no. If yes, it indicates that IE wants to register the DLL. If no, it is unnecessary;
The next step is destdir, whose value is the location where the DLL will be saved to the local hard disk. If its value is 10, place the DLL in/Windows or/winnt; if it is 11, to/Windows/system or
/Winnt/system32; if it is null (that is, there is no value), it will be placed in the Downloaded Program Files directory under/Windows or/winnt;
The last is fileversion, which is more obvious. It illustrates the version number of ctrl1.dll.
Sometimes when we use VB to develop controls, we need to install the Virtual Machine of VB. It requires some other instructions. Let's just give a brief introduction:
Add msvbvm60.dll = msvbvm60.dll in [Add. Code] (take VB6 as an example). The following is
Msvbvm60.dll:
[Msvbvm60.dll]
Hook = msvbvm60.cab _ Installer
Fileversion = 6, 0
Fileversion is obvious. If it is a version number, let's talk about Hook.
The hook area is the area to be executed during installation. It is divided into two types: conditional and unconditional. The unconditional hook area must be executed, otherwise, the execution is determined based on the conditions. The region marked with [setup hooks] is an unconditional region, as shown below:
[Setup hooks]
Hookname = Section-name
 
[Section-name]
Run = % extract_dir %/setup.exe
The unconditional region is often used to execute an installer through an INF file, which is why such a menu is installed when we right-click an INF file in the resource manager.
When ie downloads a cab file, if the file does not contain [Add. Code], it processes the [setup hooksruntime program, runs the program specified by runtime, and then processes setup.exe;
The condition area is executed under certain conditions, and the hook area specified in msvbvm60.dll is a condition area. If the CLSID or version specified in msvbvm60.dll cannot meet the requirements and the file name is not specified, the area specified by the hook.
[Msvbvm60.cab _ installer]
File-win32-x86 = http://activex.microsoft.com/controls/vb6/VBRun60.cab
Run = % extract_dir %/vbrun60.exe
The above [msvbvm60.cab _ installer] is a hook area, which also contains a file value. specifying a URL indicates that msvbvm60.dll can be downloaded from this URL. Run indicates which file to execute.
It is worth noting that, Ms has some common redistributable Microsoft DLLs
You can specify the codebase attribute as Microsoft DLLs
 
 
Create a cab file:
Cabarc n ctrl1.cab ctrl1.inf ctrl1.dll
N indicates that a new file is to be created. ctrl1.cab is the file name, ctrl1.inf is the INF of the cab, and then the file to be added to the cab. Wildcards can be used.
Then you can put the cab file on the webpage.
<Object ID = "ctrl1obj"
Classid = "CLSID :................................... .."
Codebase = "http://server.com/ctrl1.cab#version=8,0,0,5007">
</Object>
Here is also a version, but the version here refers to the control version, while the INF is the file version.
 
 
Make an electronic signature:
Download the signing tool signcode from the following URL. The address is
Http://msdn.microsoft.com/workshop/gallery/tools/authenticode/authcode.asp
From the signature authorization center such as Verisign or Microsoft Certificate running on your LAN
The server authorizes the server to get a certificate. You will get a private key when applying for authorization.
You can also use the private key created by makecert.exeand cert2spc.exe to test the function by using makecert to create an X.509 Certificate (. Cer file)
Makecert-SV mykey. pvk n "cn = my software company" mycert. Cer
Then use cert2spc to convert the. Cer file into PKCS #7 software and publish the certificate (. SPC file ),
Cert2spc mycert. Cer mycert. SPC
Use the signcode you downloaded to electronically sign your cab file
Signcode-SPC mycert. SPC-V mykey. PVK-T http ://
Timestamp.verisign.com/scripts/timstamp.dll ctrl1.cab
Signcode can also specify some other parameters. It is too long, too long.
Although the tested. CER and. SPC files can be used, you must apply for them at the time of release.
 
In fact, things are described in the SDK, but they are all in E.
---------------------------------------------------------------
 
In addition, if it is just a test, you can press enter at signcode and select the command line parameters step by step as prompted. The command line parameters are smelly and long and often encounter errors, which will save you a lot of time.
---------------------------------------------------------------
 
This is because OCX is associated with your two DLL. When the system calls the registration function in ocx, you need to call your DLL, but the system cannot find it. Therefore, loading OCX fails, causing registration failure.
 
The solution is to install the DLL in the cab installation file to the system directory, dynamically load the DLL, or specify the directory to load the DLL.

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.