A third-party IE OCX control was used in the project, but customers and test partners often reported that relevant functions could not be used normally, and there was no friendly prompt. With this in mind, there must be a check mechanism for IE OCX controls.

Check the principle

Create an ActiveXObject to check the OCX control

let newObj = new ActiveXObject(servername, typename[, location]) 

Parameters of the problem

This seems simple enough, but I’m overwhelmed. The ServerName parameter is the name of the application object.

The plug-in vendor only provides the control installer package, sample program, and CLSID

<object id="NetVideo" classid="clsid:27E1A157-6A29-48AE-86C2-14591D90B4D4"></object>

So I thought we could start with CLSID.

What is the clsids

Class Identifier, also known as CLASSID or CLSID, is a unique identifier (UUID) associated with a class object. A class object that is about to create multiple objects should register its CLSID in the task table of the system registration database so that the client can locate and load the executable code associated with the object.

The above is extracted from Baidu Baike. We can see that CLSID and UUID are used for the unique identification of plug-ins.

How to find serverName according to CLSID

Search the ActiveXObject entry on MDN, and you’ll see the following sentence:

You can be in
HKEY_CLASSES_ROOTThe registry key identified on the host PC
Servername. TypenameValue.

Oh, you can see it’s from the registry. So I ran regedit and opened the registry. Although I knew it was in the HKEY_CLASSES_ROOT directory, it was too much. How could I find it?

Of course, it still depends on the search function, so I searched according to the value of CLSID: 27E1A157-6A29-48AE-86C2-14591D90B4D4

The search time was a little long, but finally we found the location as follows:

Computer \ HKEY_CLASSES_ROOT \ SDS_CMSCtrl SDS_CMSCtrlCtrl. 1

So I guess the ServerName should be SDS_CMSCTRL. SDS_CMSCTRLCTRL.1. After testing, it is true. Check the code as follows:

try { const ocx = new ActiveXObject('SDS_CMSCtrl.SDS_CMSCtrlCtrl.1') console.log(ocx) } catch (error) { This. $alert(' You have not installed the video plugin! ', 'prompt ')}

This way, if the user has not installed the plugin, they will be immediately alerted, Perfect!


Starting link


Scan or search the Tusi blog for the latest posts!