您的位置:首页 > Web前端 > JavaScript

vbscript/javascript和COM的数据传递

2009-08-15 11:06 274 查看
我们经常会遇到,将脚本中定义的多个参数打包到一个数组中,然后将这个数组传给一个组件方法。javascript和vbscript定义数组的方式是不 同的。vbscript中的数组采用的是自动化兼容类型SAFEARRAY,对它进行遍历是很方便的。而javascript动态脚本的秘密武器--是IDispatchEx接口
对于一个基本的Object对象,即可以动态的增加或删除属性、方法,也可以生成一个自定义的类,完全基于一个IDispatchEx接口。 IDispatchEx是IDispatch的扩展,为实现动态脚本的一些动态特性量身定制。除了提供IDispatch接口的所有方法之 外,IDispatchEx还额外提供以下几个特性:

Add new members to an object ("expando") — use GetDispID with the fdexNameEnsure flag.
Delete members of an object — use DeleteMemberByName or DeleteMemberByDispID.
Case-sensitive dispatch operations — use fdexNameCaseSensitive or fdexNameCaseInsensitive.
Search for member with implicit name — use fdexNameImplicit.
Enumerate DISPIDs of an object — use GetNextDispID.
Map from DISPID to element name — use GetMemberName.
Obtain properties of object members — use GetMemberProperties.
Method invocation with this pointer — use InvokeEx with DISPATCH_METHOD.
Allow browsers that support the concept of name spaces to obtain the name space parent of an object — use GetNameSpaceParent. ,

ActiveX组件与JavaScript交互 http://hi.baidu.com/huhe/blog/item/817a59ee1ca423f8b3fb95de.html 介绍了连接点, 数据传递,等

而对于vb的safearray, 推荐使用atl的CComSafeArray<>和CComVariant<>类
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: