Microsoft Windows CE 3.0  

Make Added Interfaces Available Through NonDelegatingQueryInterface

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.

Only filters that add interfaces that are not in the base classes, such as those required for creating property pages, need implement the IUnknownmember functions (called INonDelegatingUnknownin the base classes). The base classes provide default implementations of the IUnknownmethods. IUnknownmethods in any COM-based code retrieve interfaces from an object, and increment and decrement the reference counts of those interfaces. For example, the IUnknown::QueryInterfacemethod retrieves interfaces from an object.

DirectShow defines a special IUnknownclass called INonDelegatingUnknown, whose methods do the same thing as IUnknown. (The reason for the name change is so that objects can be aggregated.) The NonDelegatingQueryInterfacemethod is called whenever some object or application wants to query a pin or filter for any interfaces it implements. If your filter implements any interface outside those listed in the base class implementation, you will need to override the NonDelegatingQueryInterfacemethod to return a pointer to the implemented interface. For example, the following code example overrides the member function to distribute references to the ISpecifyPropertyPagesand IPersistStreaminterfaces.

// Reveal our persistent stream, property pages,
and IGargle interfaces. STDMETHODIMP
CGargle::NonDelegatingQueryInterface(REFIID riid, void **ppv) { if
(riid == IID_IGargle) { return GetInterface((IGargle *) this, ppv);
} else if (riid == IID_ISpecifyPropertyPages) { return
GetInterface((ISpecifyPropertyPages *) this, ppv); } else if (riid
== IID_IPersistStream) { AddRef(); // add a reference count to
ourselves *ppv = (void *)(IPersistStream *)this; return NOERROR; }
else { return
CTransInPlaceFilter::NonDelegatingQueryInterface(riid, ppv); } } //
NonDelegatingQueryInterface
NoteThis sample calls the CTransInPlaceFilterimplementation of the member function to finish up.


 Last updated on Tuesday, May 18, 2004

© 2004 Microsoft Corporation. All rights reserved.