Is there a way to test if an ActiveX control is installed using Javascript?
3 Answers
function AXOrNull(progId) {
try {
return new ActiveXObject(progId);
}
catch (ex) {
return null;
}
}
4 Comments
James P. Wright
Well, I thought this was working, but the ActiveX files are now on my local machine, and this method always returns null. I was given this code: <object id="ASPPrinter" classid="CLSID:48CB850F-41FF-4EE6-B87D-FB9EC26D193F" codebase="ASPPrinter.CAB#version=2,1,0,200"> </object> but I'm not sure which part of that code should go in for progId. I tried it with the classid from that code and the codebase, both of them always return null.
Tomalak
When in doubt, search through the
HKCR\CLSID branch of the registry for the CLSID in question. When you've found it and the class is COM enabled, you'll find a sub-key named ProgID. The default value of that key is the ProgID you need.James P. Wright
I tried 'ASPPrinter.CAB', didn't work. Then I looked in the registry like Tomalak said, and there is no item with that CLSID. Which means that it isn't installed...but IE is no longer prompting me to install them...so I'm not sure what's happened.
Tomalak
@Pselus: Have you tried
ASPPrinterCOM.ASPPrinter? This seems to be the right ProgId according to some Google result. try{
if(new ActiveXObject("Nameofplugin")){
// write your code if plugin available
}
else{
// write your code if plugin is not available
}
}
catch(erro){
//write your code if plugin is not available
}
` Nameofplugin you can get from IE--> Tool-->ManageAddons-->Check the List and pick the name of your supportive plugin
1 Comment
Kitserve
In case anyone has the misfortune of still needing to work with ActiveX in 2023, here's a bit more detail on how to find the name. You'll need to open the page in IE mode in Edge. From there, click the IE icon to the left of the URL in the address bar. Click Manage in the popup modal that appears. You'll now see a settings tab, with Internet Options at the bottom, click the link buttom on the right of that. This opens the old IE settings window. Click the programs tab, then Manage add-ons. Toolbars and Extensions should list the add-on. (I had to click on another section first, then back in.)