VBScript “Type Mismatch” issue with “[in, out] BSTR * ” parameter

烂漫一生 提交于 2019-12-02 00:29:40

The rules for the types that VBScript is allowed to use a bit restricted compared to other languages. In your case, you have [in, out] BSTR * - this is not supported. The only type allowed for an [out] parameter is VARIANT *. VBScript would require the type to be [out, retval] in order to support the BSTR type in that position. Of course you can only have one [retval] per function so that is somewhat limiting.

In any case in your situation, you are kind of stuck since you cannot modify the server code. What I would do is write a COM wrapper in C++ that wraps the API into something that you can call. The COM wrapper can change the [out] BSTR * to an [out] VARIANT * or something else that is usable.

After consideration of wrapper workaround I found that using existing COM Automation object has some advantages versus developing your own API.

Since I already use Excel.Application object for other purposes I just created a couple of macros in VBA and execute them as needed.

More details in my blog posts:

http://automation-beyond.com/2009/09/21/gp-qtp-automation-sanscript/

http://automation-beyond.com/2009/09/23/gp-automation-vbscript-limitation/

Thank you, Albert Gareev

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