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

Most of the base classes in the DirectShow class library implement DirectShow COM interfaces. These classes produce C++ objects that provide an IUnknowninterface 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 HRESULTvalue.

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

Before calling the constructor, set the HRESULTvalue 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 HRESULTfrom a constructor.

Copy Code
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;
}