When you write code for a script client, you should use a subset of COM called Automation. What dictates that:
- all interfaces must be obtained from IDispatch
- a class must implement only one source interface
- all methods must return HRESULT; only STDMETHODIMP is valid
- argument types must be limited to the subset permitted by Automation.
In particular, this means that BOOL is not allowed, it must be VARIANT_BOOL. You declare a method that returns a boolean value by writing it to the IDL:
[id(42)] HRESULT Foo([out,retval] VARIANT_BOOL* retval);
Assign VARIANT_TRUE or VARIANT_FALSE to * retval in code. The scripting language uses natural syntax, for example var = Foo() .
You throw an exception in the scripting client, returning an HRESULT failure.
source share