Click here to Skip to main content
15,886,258 members
Articles / Programming Languages / C++

COM in plain C, Part 5

Rate me:
Please Sign up or sign in to vote.
4.94/5 (35 votes)
21 May 2006CPOL18 min read 120.2K   2.3K   101  
Add a connectable object (source/sink).
#ifndef _IEXAMPLE4_H_
#define _IEXAMPLE4_H_

#include <initguid.h>

// IExample4 type library's GUID
// {6C5A4C1A-87B3-44c1-8286-78000B2173EF}
DEFINE_GUID(CLSID_TypeLib, 0x6c5a4c1a, 0x87b3, 0x44c1, 0x82, 0x86, 0x78, 0x0, 0xb, 0x21, 0x73, 0xef);

// IExample4 object's GUID
// {6AFACEB2-9298-4d4b-80C1-F027C07B1A1E}
DEFINE_GUID(CLSID_IExample4, 0x6afaceb2, 0x9298, 0x4d4b, 0x80, 0xc1, 0xf0, 0x27, 0xc0, 0x7b, 0x1a, 0x1e);

// IExample4 VTable's GUID
// {CFADB388-9563-4591-AABB-BE7794AEC17C}
DEFINE_GUID(IID_IExample4, 0xcfadb388, 0x9563, 0x4591, 0xaa, 0xbb, 0xbe, 0x77, 0x94, 0xae, 0xc1, 0x7c);

// IExample4's VTable
#undef  INTERFACE
#define INTERFACE IExample4
DECLARE_INTERFACE_ (INTERFACE, IDispatch)
{
	// IUnknown functions
	STDMETHOD  (QueryInterface)		(THIS_ REFIID, void **) PURE;
	STDMETHOD_ (ULONG, AddRef)		(THIS) PURE;
	STDMETHOD_ (ULONG, Release)		(THIS) PURE;
	// IDispatch functions
	STDMETHOD_ (ULONG, GetTypeInfoCount)(THIS_ UINT *) PURE;
	STDMETHOD_ (ULONG, GetTypeInfo)		(THIS_ UINT, LCID, ITypeInfo **) PURE;
	STDMETHOD_ (ULONG, GetIDsOfNames)	(THIS_ REFIID, LPOLESTR *, UINT, LCID, DISPID *) PURE;
	STDMETHOD_ (ULONG, Invoke)			(THIS_ DISPID, REFIID, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *) PURE;
	// Extra functions
	STDMETHOD  (SetString)			(THIS_ BSTR) PURE;
	STDMETHOD  (GetString)			(THIS_ BSTR *) PURE;
	STDMETHOD  (GetPorts)			(THIS_ IDispatch **) PURE;
};

#endif // _IEXAMPLE4_H_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions