AfxThrowOleDispatchException

Verwenden Sie diese Funktion, um eine Ausnahme in einer OLE-Automatisierungs-Funktion auszulösen.

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

Parameter

  • wCode
    Ein Fehlercode bestimmte Anwendung.

  • lpszDescription
    Mündliche Beschreibung des Fehlers.

  • nDescriptionID
    Ressourcen-ID für die mündliche Fehlerbeschreibung.

  • nHelpID
    Ein Hilfekontext für die Datei Ihrer Anwendung der Hilfe (.HLP).

Hinweise

Die Informationen, die dieser Funktion bereitgestellt werden, können von der antreibende Anwendung (Microsoft Visual Basic oder eine andere OLE-Automatisierungs-Clientanwendung) angezeigt werden.

Beispiel

// 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;
}

Anforderungen

Header: <afxdisp.h>

Siehe auch

Referenz

COleException-Klasse

Konzepte

MFC-Makros und -globale Werte