对于从脚本调用IDispatch,DISPID_VALUE是否可靠? [英] is DISPID_VALUE reliable for invokes on IDispatchs from scripts?

查看:225
本文介绍了对于从脚本调用IDispatch,DISPID_VALUE是否可靠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继续这个问题,我很困惑是否 DISPID_VALUE on 对于脚本函数和属性(我的例子中的JavaScript),IDispatch :: Invoke()可以被认为是标准和可靠的调用由 IDispatch ?表示的实际函数?

如果是,是否在MSDN的任何地方提到?

Continuing from this question, i am confused whether DISPID_VALUE on IDispatch::Invoke() for script functions and properties (JavaScript in my case) can be considered standard and reliable for invoking the actual function that is represented by the IDispatch?
If yes, is that mentioned anywhere in MSDN?

请注意,问题是如果这种行为是可以预期的,而不是一些接口我不能预先知道的可能看起来像。

Please note that the question is about if that behaviour can be expected, not what some interfaces i can't know in advance might look like.

一个简单的用例是:

// usage in JavaScript
myObject.attachEvent("TestEvent", function() { alert("rhubarb"); }); 

// handler in ActiveX, MyObject::attachEvent(), C++
incomingDispatch->Invoke(DISPID_VALUE, IID_NULL, LOCALE_SYSTEM_DEFAULT,
                         DISPATCH_METHOD, par, res, ex, err);

编辑尝试澄清问题。

推荐答案

如果脚本定义一致,那么从脚本调用对象应该是可靠的。这应该是在MSHTML的JScript / Javascript的情况,但不幸的是有关于这个主题的真正稀疏的文档,我没有任何坚实的证据在手。

It should be reliable for invokes on objects from scripts if the script defines it consistently. This should be the case for JScript/Javascript in MSHTML, but unfortunately there is really sparse documentation on the subject, I don't have any solid proof in-hand.

在我自己的经验中,传递给attachEvent()的Javascript函数应该总是一致的 - 一个接收的对象是一个'function',只能有一个可调用的方法匹配它自己。因此,默认方法是唯一一个你可以找到,与DISPID 0. JavaScript函数通常不具有成员函数,虽然我确定有一种方法是可能的。如果它有成员函数,你会看到它们与对象上的成员函数一样。根据expando函数的规则,JScript中的成员函数将始终与IDispatchEx一致,作为对象计数添加为expandos的任何函数。

In my own experience, a Javascript function passed to attachEvent() should always be consistent- an object received that is a 'function' can only have one callable method that matches itself. Hence the default method is the only one you can find, with DISPID 0. Javascript functions don't ordinarily have member functions, although i'm sure there is a way for this to be possible. If it did have member functions, you would see them the same way as member functions on objects. Member functions in JScript will always be consistent with regard to IDispatchEx, according to the rules of expando functions, as any functions added to an object count as expandos.

IDispatchEx接口@ MSDN

这篇关于对于从脚本调用IDispatch,DISPID_VALUE是否可靠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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