简体   繁体   English

为什么Microsoft有IHTMLDocument,IHTMLDocument2,...,IHTMLDocument8?

[英]Why does Microsoft have IHTMLDocument, IHTMLDocument2, … , IHTMLDocument8?

What is the meaning of the number in the end of the interface name? 接口名称末尾的数字是什么意思? I see that IHTMLDocument3-7 have no members ( see example for #5 ), and 8 has gesture related members. 我看到IHTMLDocument3-7没有成员( 参见#5的示例 ), 8有手势相关成员。 Is the number derived from Windows version? 该数字是从Windows版本派生的吗?

This is a general feature of public COM interfaces. 这是公共COM接口的一般功能。

If you want backward compatibility, you never want to change a published interface, because that would mean all the code people wrote for, say, IE 6 stops working with IE 7, and all of their customers get mad at them, and they get mad at you. 如果你想要向后兼容,你永远不想改变一个已发布的界面,因为这意味着人们所写的所有代码,比如,IE 6停止使用IE 7,他们所有的客户都对他们生气,他们生气在你身边

So, if IE 5 adds new features that needed to be exposed, instead of changing IHTMLDocument , you create a new interface, and make IE5 support both (by inheritance, QueryInterface , or some more explicit mechanism). 因此,如果IE 5添加了需要公开的新功能,而不是更改IHTMLDocument ,则创建一个新接口,并使IE5支持(通过继承, QueryInterface或一些更明确的机制)。 And when IE 7.0.2 or IE 8 or Win XP or whatever adds even more new features, you create another one. 当IE 7.0.2或IE 8或Win XP或其他任何东西添加更多新功能时,您可以创建另一个新功能。 And so on. 等等。

While MS could have come up with descriptive suffixes instead of just sequential numbers, that would probably be more confusing than helpful. 虽然MS本可以提出描述性后缀而不仅仅是序列号,但这可能会比有用更令人困惑。 So, IHTMLDocument2 , IHTMLDocument3 , etc. are the names. 因此, IHTMLDocument2IHTMLDocument3等是名称。 They don't mean anything, except the order they were added. 它们没有任何意义,除了它们被添加的顺序。

What is the meaning of the number in the end of the interface name? 接口名称末尾的数字是什么意思?

That is the standard convention for versioning COM interfaces. 这是版本化COM接口的标准约定。 IXXX2 extends IXXX with new functions. IXXX2扩展了IXXX的新功能。 IXXX3 extends IXXX2 with new functions, and so on. IXXX3扩展了IXXX2的新功能,依此类推。 This allows clients to use older functions without breaking when new versions are released, and use newer functions when desired, even check if those functions are available before trying to call them. 这允许客户端在不释放新版本时使用旧功能,并在需要时使用更新的功能,甚至在尝试调用它们之前检查这些功能是否可用。

I see that IHTMLDocument3-7 have no members 我看到IHTMLDocument3-7没有成员

Where did you get that idea from? 你从哪里得到这个想法? Look at their actual definitions. 看看他们的实际定义。 They expose many new members from one interface to the next. 他们将许多新成员从一个界面暴露给下一个界面。

No - it just signifies a different version of the interface. 不 - 它只是表示不同版本的界面。 It has nothing to do with Windows version (and, for that matter, little/nothing to do with MSHTML version): 它与Windows版本无关(就此而言,与MSHTML版本很少/无关):

as of http://msdn.microsoft.com/en-us/library/aa752541(v=vs.85).aspx 截至http://msdn.microsoft.com/en-us/library/aa752541(v=vs.85).aspx

where we can see : 在哪里我们可以看到:

The IHTMLDocument3 interface inherits from the IDispatch interface but does not have additional members. IHTMLDocument3接口继承自IDispatch接口,但没有其他成员。

it can bee little confusing for newcomers to interface world. 对于接触世界的新人来说,这可能有点混乱。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM