what is an interfaceThe interface of a DLL can be understood as the functions it derives from, and the interface of a C + + class is a set of member functions for that class.for COM, an interface is a memory structure that contains an array of function pointers, and each array element contains an address to a function implemented by the component. For COM, the interface is such a memory structure, irrelevant details and specific language implementation. (either C # or C + + implementation, as long as you give me such a memory structure, I think you are an interface)
the role of the interfaceinterface to COM is always going to! Just remember the following three points:(1) The interface in COM is everything. (2) to the customer, a component is a collection of interfaces (the client obtains the desired interface via QueryInterface). (3) The client can only deal with COM components through the interface. The code implementation of COM interface in C + + participates in the definition of interface in COM, in C + +, the COM interface can be implemented by abstract base class. Abstract base class, in fact, defines a memory structure, the abstract base class contains only virtual functions, so it contains virtual tables and virtual pointers. As shown, abstract base classes such as
Interface IX
{
virtual void Stdmethodtype Fx1 () = 0;
virtual void Stdmethodtype Fx2 () = 0;
virtual void Stdmethodtype Fx3 () = 0;
}
It contains only a virtual pointer in memory, and this virtual pointer points to the list of implementations of a set of virtual functions (an array of function pointers). This coincides with the COM definition of the interface. Therefore, the implementation of the COM interface in C + + is implemented by the abstract base class. Subclasses inherit the abstract parent class and implement or override the abstract function. Subclasses also inherit this memory structure, which issubclasses get the ability to provide this interface to the customer, and for the component support for multiple interfaces, it can be implemented by having the subclass inherit the abstract parent class multiple.
some details1, the standard calling convention on the Microsoft platform, the COM interface provides the function to follow the Pascal calling convention, that is, the function will be returned to the caller before the argument of the stack processing. So the functions in the interface have modifiers __standcall or STDMETHODCALL2, the interface in C + + is an abstract base class implementation, but you can declare a class without class, but instead use a macro defined in OBJBASE.H
COM Technology interface