次の方法で共有


CBaseObject Class (Windows Embedded CE 6.0)

1/6/2010

Ee493378.042da71a-e289-4004-beec-1aef2287cd37(en-US,WinEmbedded.60).gif

This class is an abstract base class that is the basis for all component objects.

It maintains a process-wide count of active objects that can be queried from the DllCanUnloadNow entry point.

All Component Object Model (COM) objects are derived from the CUnknown class, which is derived from the CBaseObject class.

Other objects can be derived from CBaseObject to assist in the detection of memory leaks, because CBaseObject maintains the count of created objects.

The constructor requires a character-string name that describes the object being created.

This string can be displayed on the debugging screen to trace the creation of objects; the string is also displayed upon deletion of the object.

The string should be created in static storage rather than in local-function storage.

The string can be enclosed by the NAME macro, which compiles to NULL in release builds so the static strings are optimized out during compilation.

/* Typical object creation method */
HRESULT CSomeClass::CreateMyObject(void)
{
   HRESULT hr = NOERROR;
   CMyObject *pObject = new CMyObject(NAME("My filter object"),NULL,&hr);
      if (FAILED(hr)) {
         return hr;
   }
   if (pObject == NULL) {
      return E_OUTOFMEMORY;
   }
   m_pObject = pObject;
   return NOERROR;
}
/* Incorrect object creation method */
HRESULT CSomeClass::ThisMayAccessViolate(void)
{
   HRESULT hr = NOERROR;
   TCHAR MyObjectName[] = TEXT("My GP faulting object");
   CMyObject *pObject = new CMyObject(MyObjectName,NULL,&hr);
}

Member Functions

Member function Description

CBaseObject

Constructs a CBaseObject object.

ObjectsActive

Retrieves the count of active objects.

Requirements

Windows Embedded CE Windows CE 2.12 and later
Note Microsoft DirectShow applications and DirectShow filters have different include file and Library requirements
For more information, see Setting Up the Build Environment

See Also

Reference

DirectShow Classes