Been studying COM for some time now and for the life of me I can't find out how some of these standard interfaces such as IID_IConnectionPointContainer, IID_IConnectionPoint, etc., are actually defined. I can pass these IIDs in QueryInterface() calls and successfully retrieve pointers to them, so they must be actually defined somewhere, right?

In ocidl.h can be found things like this...

typedef IConnectionPoint __RPC_FAR *PCONNECTIONPOINT;
typedef IConnectionPoint __RPC_FAR *LPCONNECTIONPOINT;
EXTERN_C const IID IID_IConnectionPoint;

#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("B196B286-BAB4-101A-B69C-00AA00341D07")
IConnectionPoint : public IUnknown
{
 public:
 virtual HRESULT STDMETHODCALLTYPE GetConnectionInterface(IID __RPC_FAR *pIID)=0;
 virtual HRESULT STDMETHODCALLTYPE GetConnectionPointContainer(IConnectionPointContainer __RPC_FAR *__RPC_FAR *ppCPC)=0;
 virtual HRESULT STDMETHODCALLTYPE Advise(IUnknown __RPC_FAR *pUnkSink,DWORD __RPC_FAR *pdwCookie)=0;
 virtual HRESULT STDMETHODCALLTYPE Unadvise(DWORD dwCookie)=0;
 virtual HRESULT STDMETHODCALLTYPE EnumConnections(IEnumConnections __RPC_FAR *__RPC_FAR *ppEnum)=0;
};
#else 	/* C style interface */
typedef struct IConnectionPointVtbl
{
 BEGIN_INTERFACE
 HRESULT (STDMETHODCALLTYPE __RPC_FAR* QueryInterface)(IConnectionPoint __RPC_FAR* This,REFIID riid,void __RPC_FAR *__RPC_FAR *ppvObject);
 ULONG (STDMETHODCALLTYPE __RPC_FAR* AddRef)(IConnectionPoint __RPC_FAR* This);
 ULONG (STDMETHODCALLTYPE __RPC_FAR* Release)(IConnectionPoint __RPC_FAR* This);
 HRESULT (STDMETHODCALLTYPE __RPC_FAR* GetConnectionInterface)(IConnectionPoint __RPC_FAR* This, IID __RPC_FAR* pIID);
 HRESULT (STDMETHODCALLTYPE __RPC_FAR* GetConnectionPointContainer)(IConnectionPoint __RPC_FAR* This,IConnectionPointContainer __RPC_FAR* __RPC_FAR* ppCPC);
 HRESULT (STDMETHODCALLTYPE __RPC_FAR* Advise)(IConnectionPoint __RPC_FAR* This, IUnknown __RPC_FAR* pUnkSink, DWORD __RPC_FAR* pdwCookie);
 HRESULT (STDMETHODCALLTYPE __RPC_FAR* Unadvise)(IConnectionPoint __RPC_FAR* This, DWORD dwCookie);
 HRESULT (STDMETHODCALLTYPE __RPC_FAR* EnumConnections)(IConnectionPoint __RPC_FAR* This, IEnumConnections __RPC_FAR* __RPC_FAR* ppEnum);
 END_INTERFACE
}IConnectionPointVtbl;

...which includes this line...

EXTERN_C const IID IID_IConnectionPoint;

But of course that has an EXTERN modifier in front of it. Does that MIDL_INTERFACE macro somehow cause it to be defined. Quite honestly, I'm not sure just what that does. I've looked it up but still not sure exactly what it does.

In terms of IID_IConnectionPoint I've used file searching tools to scour /include folders of VC++ 6 and Dev-CPP but any time I find it there is always an EXTERN in front of it. These interfaces can be found under the interface key in the registry too, but there again, to use them in a program they have to be actually defined? Or am I thinking wrong somehow???

Recommended Answers

All 2 Replies

If you are using a Microsoft compiler, put your cursor on the object you want to find and right-click. That will bring up a pop-up menu which will give you the option to find the declaration of the object or class.

If you are new to COM programming, buy a book because it is a very complex subject.

Thanks for the tip AncientDragon. Believe it or not I was doing command line compiling with Notepad, but I took your advice and created a VC++ 6 project with the source. When I did the show definition thing it took me to ocidl.h as I described above where it is defined as...

EXTERN_C const IID IID_IConnectionPoint;

If a c++ file EXTERN_C resolves to extern "C" I believe. But that still doesn't actually define it if its prefixed with any form of the C keyword 'extern' does it?

I've got several COM books already. What I need are more brains!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.