English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2006-06-26 23:50:05 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

The layout of a COM object
The Win32 COM calling convention specifies the layout of the virtual method table (vtable) of an object. If a language/compiler wants to support COM, it must lay out its object in the specified manner so other components can use it.

It is no coincidence that the Win32 COM object layout matches closely the C++ object layout. Even though COM was originally developed when C was the predominant programming language, the designers saw fit to "play friendly" with the up-and-coming new language C++.

The layout of a COM object is made explicit in the header files for the various interfaces. For example, here's IPersist from objidl.h, after cleaning up some macros.

typedef struct IPersistVtbl
{
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
IPersist * This,
/* [in] */ REFIID riid,
/* [iid_is][out] */ void **ppvObject);

ULONG ( STDMETHODCALLTYPE *AddRef )(
IPersist * This);

ULONG ( STDMETHODCALLTYPE *Release )(
IPersist * This);

HRESULT ( STDMETHODCALLTYPE *GetClassID )(
IPersist * This,
/* [out] */ CLSID *pClassID);

} IPersistVtbl;

struct IPersist
{
const struct IPersistVtbl *lpVtbl;
};

2006-06-26 23:59:27 · answer #1 · answered by Joe_Young 6 · 0 0

Well, try out these URLs.

2006-06-27 05:38:29 · answer #2 · answered by griz803 5 · 0 0

visit www.codeproject.com

2006-06-27 03:02:26 · answer #3 · answered by kamyar_souri 1 · 0 0

http://cs.ua.edu/components/borie/com.htm

http://www.developerfusion.co.uk/c/

well i can help this much only

2006-06-27 21:16:49 · answer #4 · answered by Krex 3 · 0 0

fedest.com, questions and answers