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???