INonDelegatingUnknown
[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
The INonDelegatingUnknown
interface is a version of IUnknown that is renamed to enable support for both nondelegating and delegating IUnknown interfaces in the same COM object.
Syntax
interface INonDelegatingUnknown
{
virtual HRESULT NonDelegatingQueryInterface(REFIID riid, LPVOID *ppv) PURE;
virtual ULONG NonDelegatingAddRef(void) PURE;
virtual ULONG NonDelegatingRelease(void) PURE;
};
Remarks
To use INonDelegatingUnknown
for multiple inheritance, perform the following steps.
Derive your class from an interface, for example, IMyInterface.
Include DECLARE_IUNKNOWN in your class definition to declare implementations of QueryInterface, AddRef, and Release that call the outer unknown.
Override NonDelegatingQueryInterface to 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 INonDelegatingUnknown
for nested interfaces, perform the following steps:
Declare a class derived from CUnknown.
Include DECLARE_IUNKNOWN in your class definition.
Override NonDelegatingQueryInterface to 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::GetOwner to 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 HRESULT to the CUnknown constructor, 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 NonDelegatingQueryInterface with 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.
Requirements
Requirement | Value |
---|---|
Header |
|
Library |
|
See also