Share via


CObject::GetRuntimeClass

This method retrieves a pointer to the CRuntimeClass structure that corresponds to the class of this object. There is one CRuntimeClass structure for each CObject-derived class.

virtual CRuntimeClass* GetRuntimeClass( )
const; 

Return Value

A pointer to the CRuntimeClass structure corresponding to the class of this object; it is never NULL.

Remarks

The CRuntimeClass structure members are as follows:

  • LPCSTR m_lpszClassName   A null-terminated string containing the ASCII class name.
  • int m_nObjectSize   The size of the object, in bytes. If the object has data members that point to allocated memory, the size of that memory is not included.
  • UINT m_wSchema   The schema number, –1 for nonserializable classes. See the IMPLEMENT_SERIAL macro for a description of schema number.
  • CObject* ( PASCAL* m_pfnCreateObject )( )   A function pointer to the default constructor that creates an object of your class, valid only if the class supports dynamic creation; otherwise, returns NULL.
  • CRuntimeClass* ( PASCAL* m_pfn_GetBaseClass )( )   If your application is dynamically linked to the AFXDLL version of MFC for Windows CE, a pointer to a function that returns the CRuntimeClass structure of the base class.
  • CRuntimeClass* m_pBaseClass   If your application is statically linked to MFC for Windows CE, a pointer to the CRuntimeClass structure of the base class.

This function requires use of the IMPLEMENT_DYNAMIC, IMPLEMENT_DYNCREATE, or IMPLEMENT_SERIAL macro in the class implementation. You will get incorrect results otherwise.

Example

See CObList::CObList for a listing of the CAge class used in all CObject examples.

// Example for CObject::GetRuntimeClass.
CAge a(21);
CRuntimeClass* prt = a.GetRuntimeClass();
ASSERT( strcmp( prt->m_lpszClassName, "CAge" )  == 0 );

Requirements

**  Windows CE versions:** 1.0 and later  
  Header file: Declared in Afx.h
  Platform: H/PC Pro, Palm-size PC, Pocket PC

See Also

CObject::IsKindOf