问题
Ist it possible to cal a COM method with the signature
HRESULT Foo(BSTR in, [out] BSTR * out1, [out] BSTR * out2)
from VBScript?
The following:
Dim a;
Dim b;
component.Foo "something", a, b
gives an error about incompatible types.
I still could change the signature of the method.
回答1:
Looks like output parameters are not supported; while ByRef
/ [in, out]
parameters are, but only on VARIANT
parameters.
From the following KB article:
INFO: Type mismatch errors when you pass parameters from an ASP component to Visual Basic Component @ support.microsoft.com
"VBScript only supports VARIANT ByRef parameters. You can use VBScript to call a procedure that takes ByRef strings, but the default behavior of components built with Visual Basic is to fail with a type mismatch error when trying to pass ByRef parameters to these components. OLE Automation's default type-coercion function fails when asked to convert a ByRef variant into any other ByRef type."
Also, here are other links on the topic:
In, Out, In-Out, Make up your mind Already @ MSDN blogs
VBScript “Type Mismatch” issue with “[in, out] BSTR * ” parameter SO Question
来源:https://stackoverflow.com/questions/5646760/calling-com-method-with-foo-out-bstr-value-from-vbscript