简体   繁体   English

在vtbl中命名函数指针

[英]Naming function pointers in the vtbl

Sorry for the beginner question. 对不起初学者的问题。

In really good article Com in plain C I read this sentence: 在非常好的文章Com in plain C我读了这句话:

One requirement of a COM object is that the first three members of our VTable (ie, our IExampleVtbl struct) must be called QueryInterface, AddRef, and Release. COM对象的一个​​要求是我们的VTable的前三个成员(即我们的IExampleVtbl结构)必须被称为QueryInterface,AddRef和Release。

Is this true? 这是真的?

What if change names, but parameters, calling convention and return values will be same ? 如果更改名称,但参数,调用约定和返回值会相同怎么办?

Do you still work this? 你还在做这个吗? If not why? 如果不是为什么?

Many thanks for response. 非常感谢您的回复。 (Positive or negative.) (正面或负面。)

Every COM interface must derive from IUnknown. 每个 COM接口都必须从IUnknown派生。 Which provides essential services: memory management (AddRef and Release) and the ability to discover other interfaces implemented by the COM object (QueryInterface). 它提供了基本服务:内存管理(AddRef和Release)以及发现COM对象实现的其他接口(QueryInterface)的能力。 The v-table for a COM interface therefore always starts with 3 function pointers to the implementation of these methods. 因此,COM接口的v表始终以3个函数指针开始,这些函数指向这些方法的实现。 The actual names of the functions or what language they were written in do not matter at all, COM only cares about the function pointers. 函数的实际名称或它们所用的语言根本不重要,COM只关心函数指针。

You can name the implementation functions anything you want. 您可以根据需要命名实现函数。 Intentionally not using the IUnknown function names is unwise. 故意不使用IUnknown函数名称是不明智的。

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

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