Is there a way to test if an ActiveX control is installed using Javascript?
+3
A:
function AXOrNull(progId) {
try {
return new ActiveXObject(progId);
}
catch (ex) {
return null;
}
}
Tomalak
2010-02-01 18:25:17
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.
Pselus
2010-02-01 19:49:21
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.
Tomalak
2010-02-01 20:07:07
AXOrNull('ASPPrinter.CAB')
drlouie - louierd
2010-02-01 20:08:12
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.
Pselus
2010-02-01 20:17:32
@Pselus: Have you tried `ASPPrinterCOM.ASPPrinter`? This seems to be the right ProgId according to some Google result.
Tomalak
2010-02-03 15:10:08
+1
A:
Solution, try to invoke a new ActiveXObject:
function testForActiveX(){
tester = null;
try {
tester = new ActiveXObject('htmlfile');
}
catch (e) {
// catch the exception
}
if (tester) {
// ActiveX is installed
return true;
}
return false;
}
drlouie - louierd
2010-02-01 18:28:57