VBScript“类型不匹配”问题与“[in,out] BSTR *”参数 [英] VBScript "Type Mismatch" issue with "[in, out] BSTR * " parameter

查看:370
本文介绍了VBScript“类型不匹配”问题与“[in,out] BSTR *”参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用第三方COM对象,它的一些方法将值作为BSTR指针传回。由于VBscript仅支持变体类型尝试以像Object.Method(sMyString)这样的方式使用,以类型不匹配错误合理结束。

I'm working with third-party COM object that has some of its methods passing values back as BSTR pointer. Since VBscript supports only Variant type attempts to use in a way like Object.Method(sMyString) reasonably end with "Type mismatch" error.

我怀疑这个错误是由COM对象本身而不是VBscript解释器生成的,因为对象获取字符串而不是指针。我试图解决它定义字符串数组,但它仍然是一样的错误。

I suspect this error is generated by the COM object itself rather then VBscript interpreter since the object gets string instead of pointer. I tried to workaround it defining array of strings but it's still the same error.

所以我想知道是否有人有类似的问题和解决方法被利用。

So I was wondering if someone had similar problem and what workarounds were utilized.

只是为了强调。我不能控制COM对象。它在供应商的应用程序。

Just to emphasize. I DO NOT have control over COM object. It's in Vendor's application. I have to use it "as is".

谢谢你,
Albert Gareev

Thank you, Albert Gareev

推荐答案

考虑到wrapper解决方法后,我发现使用现有的COM Automation对象比开发自己的API有一些优势。

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

Excel.Application对象用于其他目的我刚刚在VBA中创建了几个宏,并根据需要执行它们。

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/

谢谢您,
Albert Gareev

Thank you, Albert Gareev

这篇关于VBScript“类型不匹配”问题与“[in,out] BSTR *”参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆