Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling COM method with Foo(..., [out] BSTR * value) from VBScript

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.

like image 431
peterchen Avatar asked Oct 11 '22 07:10

peterchen


1 Answers

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

like image 78
meklarian Avatar answered Oct 27 '22 10:10

meklarian