CFactoryTemplate::m_lpfnNew

 
Microsoft DirectShow 9.0

CFactoryTemplate::m_lpfnNew

Pointer to a function that creates an instance of the object.

Syntax

  typedef CUnknown *(CALLBACK *LPFNNewCOMObject)(LPUNKNOWN pUnkOuter, HRESULT *phr);

LPFNNewCOMObject m_lpfnNew;

Remarks

In your DLL, declare a static function that returns a pointer to a new instance of the object. In the factory template, set the m_lpfnNew member variable to the address of this static function.

The following example shows a typical function for m_lpfnNew:

CUnknown * WINAPI CMyComponent::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr) 
{
    CMyComponent *pNewObject = new CMyComponent(NAME("My Component"), pUnk, pHr );
    if (pNewObject == NULL) 
{
        *phr = E_OUTOFMEMORY;
    }
    return pNewObject;
} 

Requirements

**  Header:** Declared in Combase.h; include Streams.h.

**  Library:** Use Strmbase.lib (retail builds) or Strmbasd.lib (debug builds).

See Also