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

时光怂恿深爱的人放手 提交于 2020-01-13 10:50:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!