views:

459

answers:

2

I have an ActiveX (3rd party, no source) with a method that has a reference parameter like this:

HRESULT GetSomething(
[in] short param1,
[out] BSTR* someString);

In C++ you'd execute it like this:

BSTR someString = NULL
m_activeX.GetSomething(0, &someString);

How would I execute this via Javascript? All other functions in the ActiveX work fine, but this one looks impossible? If not possible in Javascipt, is it in VBScript? I have had no luck in either.

BTW, This must be done in Internet Explorer

+1  A: 

I can't give you a definite answer, but I don't believe it can be done. I hope somebody will prove me wrong, but here's why I think it can't work...

In Javascript, all variables are passed by value. In IE, you'll create an instance of the ActiveXObject javascript class to wrap your COM object. Even if that wrapper object could get the value from your COM object, there's no way in Javascript for it to pass that value back to you.

If you know that you'll be running in IE on Windows, you could try using vbscript instead of javascript. Vbscript does support pass-by-reference so you might have more luck with that.

I hope that helps.

Martin
A: 

// Using javascript

var someString = activeXObj.GetSomething(0);

ddouble
AFAIK, this would only work with an `[out, retval]` parameter, not `[out]` (see [this question](http://stackoverflow.com/questions/1575818/differences-between-in-out-and-out-retval-in-com-idl-definitions))
Helen