Condividi tramite


AfxThrowOleDispatchException

Utilizzare questa funzione per generare un'eccezione all'interno di una funzione di automazione OLE.

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

Parametri

  • wCode
    Un codice di errore specifico all'applicazione.

  • lpszDescription
    La descrizione dell'errore.

  • nDescriptionID
    ID di risorsa per la descrizione di errore da.

  • nHelpID
    Un contesto del file della guida dell'applicazione (.HLP).

Note

Informazioni fornite a questa funzione possono essere visualizzate dall'applicazione movente (Microsoft Visual Basic o un'altra applicazione client di automazione OLE).

Esempio

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

Requisiti

Header: <afxdisp.h>

Vedere anche

Riferimenti

Classe COleException

Concetti

Macro MFC e Globals