Microsoft Windows CE 3.0  

CBaseObject Class

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.

The CBaseObjectclass 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 DllCanUnloadNowentry point.

All Component Object Model (COM) objects are derived from the CUnknownclass, which is derived from the CBaseObjectclass. Other objects can be derived from CBaseObjectto assist in the detection of memory leaks, because CBaseObjectmaintains 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 will also be 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 NAMEmacro, which compiles to NULL in retail builds so that 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

CBaseObject Constructs a CBaseObjectobject.
ObjectsActive Retrieves the count of active objects.