Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C++
MFC
 AfxThrowOleDispatchException
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
MFC Library Reference
AfxThrowOleDispatchException

Use this function to throw an exception within an OLE automation function.

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

An error code specific to your application.

lpszDescription

Verbal description of the error.

nDescriptionID

Resource ID for the verbal error description.

nHelpID

A help context for your application's help (.HLP) file.

The information provided to this function can be displayed by the driving application (Microsoft Visual Basic or another OLE automation client application).

Visual C++
// 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;
}

Header: <afxdisp.h>

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker