Microsoft Windows CE 3.0  

INonDelegatingUnknown::INonDelegatingUnknown

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

A version of IUnknownrenamed to enable a class to support both nondelegating and delegating IUnknowninterfaces in the same COM object. The interface supports the following three methods, in vtable order.

HRESULT NonDelegatingQueryInterface(
REFIID
iid
,
void**
ppvObject
);
ULONG
NonDelegatingAddRef(void);
ULONG NonDelegatingRelease(void);

Remarks

To use INonDelegatingUnknownfor multiple inheritance, perform the following steps:

Derive your class from an interface, for example, IMyInterface.

Include DECLARE_IUNKNOWNin your class definition to declare implementations of QueryInterface, AddRef, and Releasethat call the outer unknown.

Override NonDelegatingQueryInterfaceto expose IMyInterface with code such as the following:

if (riid == IID_IMyInterface) { return
GetInterface((IMyInterface *) this, ppv); } else { return
CUnknown::NonDelegatingQueryInterface(riid, ppv); }

Declare and implement the member functions of IMyInterface.

To use INonDelegatingUnknownfor nested interfaces, perform the following steps:

Declare a class derived from CUnknown.

Include DECLARE_IUNKNOWNin your class definition.

Override NonDelegatingQueryInterfaceto expose IMyInterface with the code such as the following:

if (riid == IID_IMyInterface) { return
GetInterface((IMyInterface *) this, ppv); } else { return
CUnknown::NonDelegatingQueryInterface(riid, ppv); }

Implement the member functions of IMyInterface. Use CUnknown::GetOwnerto access the COM object class.

In your COM object class, make the nested class a friend of the COM object class, and declare an instance of the nested class as a member of the COM object class.

Because you must always pass the outer unknown and an HRESULTto the CUnknownconstructor, you can't use a default constructor. You have to make the member variable a pointer to the class and make a new call in your constructor to actually create it.

Override the NonDelegatingQueryInterfacewith code such as the following:

if (riid == IID_IMyInterface) { return
m_pImplFilter-> NonDelegatingQueryInterface(IID_IMyInterface,
ppv); } else { return CUnknown::NonDelegatingQueryInterface(riid,
ppv); }

You can have mixed classes that support some interfaces through multiple inheritance and some interfaces through nested classes.