Compartir a través de


AfxThrowOleDispatchException

Utilice esta función para producir una excepción dentro de una función de automatización OLE.

void AFXAPI AfxThrowOleDispatchException(
   WORD wCode,
   LPCSTR lpszDescription,
   UINT nHelpID = 0 
);
void AFXAPI AfxThrowOleDispatchException(
   WORD wCode,
   UINT nDescriptionID,
   UINT nHelpID =  -1 
);

Parámetros

  • wCode
    Una específica del código de error a la aplicación.

  • lpszDescription
    Descripción verbal de error.

  • nDescriptionID
    Id. de recurso en la descripción de error verbal.

  • nHelpID
    Un contexto de ayuda para el archivo de ayuda de la aplicación (.HLP).

Comentarios

La información proporcionada a esta función puede mostrar por la aplicación de control (Microsoft Visual Basic u otra aplicación cliente de automatización OLE).

Ejemplo

// Sort is method of automation class CStrArrayDoc
long CStrArrayDoc::Sort(VARIANT* vArray)
{
   USES_CONVERSION;

   // Type check VARIANT parameter. It should contain a BSTR array
   // passed by reference. The array must be passed by reference; it is
   // an in-out-parameter.

   // throwing COleDispatchException allows the EXCEPINFO structure of 
   // IDispatch::Invoke() to set
   if (V_VT(vArray) != (VT_ARRAY | VT_BSTR))
      AfxThrowOleDispatchException(1001, 
         _T("Type Mismatch in Parameter. Pass a string array by reference"));

   // ...
   // ...

   return 0;
}

Requisitos

Header: <afxdisp.h>

Vea también

Referencia

COleException (Clase)

Conceptos

Macros y funciones globales de MFC