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 this page is also available for
4/8/2010

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.

Syntax

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

Remarks

To use INonDelegatingUnknownfor multiple inheritance, perform the following steps:

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

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

  3. Override NonDelegatingQueryInterfaceto expose IMyInterfacewith code such as the following.

    Copy Code
    	 if (riid == IID_IMyInterface) {
    		 return GetInterface((IMyInterface *) this, ppv);
    	 } else {
    		 return CUnknown::NonDelegatingQueryInterface(riid, ppv);
    	 }
    
  4. Declare and implement the member functions of IMyInterface.

To use INonDelegatingUnknownfor nested interfaces, perform the following steps:

  1. Declare a class derived from CUnknown.

  2. Include DECLARE_IUNKNOWNin your class definition.

  3. Override NonDelegatingQueryInterfaceto expose IMyInterfacewith the code such as the following:

    Copy Code
    	 if (riid == IID_IMyInterface) {
    		 return GetInterface((IMyInterface *) this, ppv);
    	 } else {
    		 return CUnknown::NonDelegatingQueryInterface(riid, ppv);
    	 }
    
  4. Implement the member functions of IMyInterface.

    Use CUnknown::GetOwnerto access the COM object class.

  5. 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 cannot use a default constructor. You must 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.

Copy Code
	 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.

Requirements

Windows Embedded CE Windows CE 2.12 and later
Windows Mobile Windows Mobile Version 5.0 and later
Note Microsoft DirectShow applications and DirectShow filters have different include file and Library requirements
For more information, see Setting Up the Build Environment,
Version 2.12 requires DXPAK 1.0 or later

See Also