Compartilhar via


Base Classes (Windows CE 5.0)

Send Feedback

Most of the base classes in the DirectShow class library implement DirectShow COM interfaces. These classes produce C++ objects that provide an IUnknown interface so external components can access the interfaces that the objects support.

The following topics discuss DirectShow base classes:

CBaseObject and CUnknown Classes

Base Classes that Implement Interfaces

Base Class Constructors

Many constructors in the DirectShow base classes take a pointer to an HRESULT value.

If the constructor fails, it sets the value to an error code.

Before calling the constructor, set the HRESULT value to S_OK.

When the constructor returns, check the value.

A failure code means the constructor failed, possibly leaving the object in an invalid state.

The following code shows how to check the HRESULT from a constructor.

HRESULT hr = S_OK;  // Set the HRESULT to S_OK first.
CMemAllocator pAlloc = new CMemAllocator(NAME("MyAllocator"), 0, &hr);
if (pAlloc == NULL) 
{
    return E_OUTOFMEMORY;
}
else if (FAILED(hr))
{
    return E_FAIL;
}

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.