但C是利用"structure"或"record"类型,将上包含双重的指向函数指针表的成员,实现接口描述,从而编写COM和使用COM的。如一个字典的接口:
struct IDictionaryVtbl;
struct IDictionary
{
IDictionaryVtbl *pVtbl;
};
struct IDictionaryVbtl
{
BOOL(* Initialize)(IDictionary *this);
BOOL(* LoadLibrary)(IDictionary *this,String);
BOOL(* InsertWord)(IDictionary *this,String,String);
BOOL(* DeleteWord)(IDictionary *this,String);
BOOL(* LookupWord)(IDictionary *this,String,String *);
BOOL(* RestoreLibrary)(IDictionary *this,String);
BOOL(* FreeLibrary)(IDictionary *this);
};
说明:(1) 接口函数第一个参数为指向Idictionary的指针;(2)字符串采用UNICODE;(3)尽量采用_stdcall或pascal调用习惯(not -cadcl);(4)只是描述