
Passing optional object arguments from COM components
Solution 1. Use
interface IFoo1 : IDispatch {
HRESULT Open (
[in] Mode Mode,
[in, defaultvalue(NULL)] IUknown* Test,
[out, retval] IFoo2** Module );
Quote:
}
Then QI for ITest inside your IFoo1::Open implemetation. But it may not work with
early versions of Automation (OLEAUT32.DLL)
Solution 2. Works for sure, but more handwork:
interface IFoo1 : IDispatch {
HRESULT Open (
[in] Mode Mode,
[in, optional] VARIANT* Test,
[out, retval] IFoo2** Module );
Quote:
}
Then analyse Test by your own.
--
Regards,
Andrew Nosenko,
Senior Software Engineer
Mead & Company
Innovative browser extensions for weblications:
http://www.meadroid.com/wpm/
http://www.meadroid.com/scriptx/
MeadCo HTML printing article and samples on the MSDN:
http://msdn.microsoft.com/workshop/author/script/dhtmlprint.asp
Hello,
I have a dual interface COM component with a method that takes an
optional interface as one of its arguments, e.g. the IDL looks like
...
interface IFoo1 : IDispatch {
HRESULT Open (
[in] Mode Mode,
[in, defaultvalue(NULL)] ITest* Test,
[out, retval] IFoo2** Module );
Quote:
}
Calling this method from JScript with one argument results in a "Type
Mismatch" error. I'm presuming that NULL gets transformed into a
variant that's not compatible with an IDispatch or IUnknown variant?
Dropping the defaultvalue modifier, and passing null as the second
argument produced the same error. So is there any mechanism for
JScript to pass a null object pointer to a COM component, or am I
doomed to use variants explicitly here? I'd like to avoid this if
possible as the component is also used by other languages. I'd like to
preserve as much typing as I can at the IDL level, even if it gets
coerced to variants behind the scenes in JScript.
Thanks in advance for any help/suggestions,
Kevin Mitchell
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.