First, correct one idea. The so-called automatic installation is not forced installation. Otherwise, it becomes a rogue software. Even if it is a well-known ActiveX such as Silverlight and flash, users have the right to choose to install or not to install it.
The more orthodox solution is to prompt the user to set ie permissions, add codebase = 'ocx download path' to the object, and then create a digital certificate. I personally think this is complicated.
My solution:
1. First Use js to check whether ActiveX is available
Code
< Object ID = 'X' Name = 'X' Classid = 'Clsid: 82ab2103-26bc-4999-8dde-df1a647d96e5' > </ Object >
< Script Type = "Text/JavaScript" >
Try {
VaR X = Document. getelementbyid ( ' X ' );
If (X. Caption = Undefined ){
If (Confirm ( ' The required ActiveX plug-in is not installed on your machine! Need to be installed? ' )){
Window. Open ( ' Http://www.youname.com/setup.exe ' )
};
}
}
Catch (E ){
}
</ Script >
Note: ActiveX developed by Delphi must have the caption attribute by default. If the caption attribute is undefined, the control is not installed. After asking the user, the system jumps to download the installation file. ActiveX developed by other tools can also be detected using similar methods.
2. Download the Installation File
The installation of ActiveX is to call the regsvr32 command to register OCX. Therefore, basically the installation is a copy & run process, which can be done with WinRAR.
WinRAR can package files into self-extracting files in EXE format, and execute some commands before or after decompression, or even start -->Program"Generate shortcuts. These are enough for us to build an installer.
(1)Write several batches for automatic registration or anti-registration and deletion.
Install. BAT reference content: (assume that the program is installed/decompressed to the C: \ capture directory)
Regsvr32 c: \ capture \ qqcaptureactivex. ocx-S
Uninstall. BAT reference content:
Regsvr32 c: \ capture \ qqcaptureactivex. ocx/u
Delete. BAT reference content:
Regsvr32 c: \ capture \ qqcaptureactivex. ocx/u-s
Del c: \ capture \ cameradll. dll
Del c: \ capture \ qqcaptureactivex. ocx
Del c: \ capture \ install. bat
Del c: \ capture \ Uninstall. bat
Del c: \ capture \ Delete. bat
Rd c: \ capture
(2)Start to use WinRAR to create the installation program