CRuntimeClass::FromName

Chiamare questa funzione per recuperare la struttura CRuntimeClass associata al nome comune.

static CRuntimeClass* PASCAL FromName(
   LPCSTR lpszClassName 
);
static CRuntimeClass* PASCAL FromName(
   LPCWSTR lpszClassName 
);

Parametri

  • lpszClassName
    Il nome comune di una classe derivata da CObject.

Valore restituito

Un puntatore a un oggetto CRuntimeClass, corrispondente al nome come passato in lpszClassName.La funzione restituisce NULL se nessun nome della classe corrispondente è stato trovato.

Esempio

// This example creates an object if CAge is defined.

CRuntimeClass* pClass = CRuntimeClass::FromName(_T("CAge"));
if (pClass == NULL)
{
   // not found, display a warning for diagnostic purposes
   AfxMessageBox(_T("Warning: CMyClass not defined"));
   return NULL;
}

// attempt to create the object with the found CRuntimeClass
CObject* pObject = pClass->CreateObject();

Requisiti

Header: afx.h

Vedere anche

Riferimenti

Struttura di CRuntimeClass

Grafico della gerarchia

CRuntimeClass::m_lpszClassName