views:

21

answers:

2

Hi every one. I wanted to know if the XPCOM JS can call an external dll function ?

I have a dll that exposes certain functions. I want my XPCOM JS function to be able to call the dll function. Is it possible ?

+1  A: 

well you cannot call external dlls from JS unless the dlls are XPCOM components take a look here https://developer.mozilla.org/en/How_to_build_a_binary_XPCOM_component_using_Visual_Studio then u can use JS to call the functions exposed by the dlls by defining them in the XPT

edit a tutorial : http://nerdlife.net/building-a-c-xpcom-component-in-windows/

jknair
Does XPCOM provide any interface that would help us load a dll file in JS XPCOM itself ?
Sharad
In case it doesn't how should I go about it ? I will have to write an XPCOM dll that will expose the functions of my dll to my extension and then use the JS XPCOM file to call the exposed function ? Basically I end up with 2 XPCOM components, 1 written in JS and another in C++.
Sharad
absolutely !!! dont forget the xpt to act as th iterface between the languages
jknair
Note that it's much easier to use JS C-types if you plan on supporting Firefox 4 or later.
sdwilsh
A: 

In Firefox 4 and later, you can use JS C-Types to accomplish this.

sdwilsh