Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function sets the error information object for the current thread of execution.

Syntax

HRESULT SetErrorInfo( 
  DWORD 
dwReserved, 
  IErrorInfo* 
perrinfo 
); 

Parameters

dwReserved

[in] Reserved for future use; must set to zero.

perrinfo

[in] Pointer to an error object that supports IErrorInfo.

Return Value

Returns the HRESULT value S_OK if successful.

Remarks

This function releases the existing error information object, if one exists, and sets the pointer to perrinfo.

Use this function after creating an error object that associates the object with the current thread of execution.

If the property or method that calls SetErrorInfois called by DispInvoke, DispInvoke does the following:

  • Fills the EXCEPINFO parameter with the values specified in the error information object

  • Returns DISP_E_EXCEPTION when the property or method returns a failure value for DispInvoke.

Virtual function table (VTBL) binding controllers that do not use IDispatch::Invokecan get the error information object by using GetErrorInfo. This allows an object that supports a dual interface to use SetErrorInfo, regardless of whether the client uses VTBL binding or IDispatch.

Passing invalid (and under some circumstances NULL) pointers to this function causes an unexpected termination of the application.

Example

The following example code shows how to use the SetErrorInfofunction.

To use this function correctly, make sure that you have an EXCEPINFOstructure that is populated with information about the exception that occurred.

Copy Code
ICreateErrorInfo *pcerrinfo;
  IErrorInfo *perrinfo;
  HRESULT hr;
hr = CreateErrorInfo(&pcerrinfo);
hr = pcerrinfo->SetGUID(IID_IHello);
hr = pcerrinfo->SetSource(m_excepinfo.bstrSource);
hr = pcerrinfo->SetDescription(m_excepinfo.bstrDescription);
hr = pcerrinfo->SetHelpFile(NULL);
hr = pcerrinfo->SetHelpContext(0);

hr = pcerrinfo->QueryInterface(IID_IErrorInfo, (LPVOID FAR*)
&perrinfo);
if (SUCCEEDED(hr))
  {
	SetErrorInfo(0, perrinfo);
	perrinfo->Release();
  }
pcerrinfo->Release();

Requirements

Header oleauto.h
Library oleaut32.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also