This function sets the error information object for the current thread of execution.
At a Glance
Header file: | Oleauto.h |
Windows CE versions: | 2.0 and later |
Syntax
HRESULT SetErrorInfo( DWORD dwReserved, IErrorInfo * perrinfo);
Parameters
dwReserved
Reserved for future use; set to zero.
perrinfo
Pointer to an error object.
Return Values
One of the values obtained from the returned HRESULT and described in the following table is returned.
Value | Description |
S_OK | Success. |
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 SetErrorInfo is called by DispInvoke, then DispInvoke will fill the EXCEPINFO parameter with the values specified in the error information object. DispInvoke will return DISP_E_EXCEPTION when the property or method returns a failure return value for DispInvoke.
Virtual function table (VTBL) binding controllers that do not use IDispatch::Invoke can 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 into this function any invalid and, under some circumstances, NULL pointers will result in unexpected termination of the application.
Example
ICreateErrorInfo *pcerrinfo;
IErrorInfo *perrinfo;
HRESULT hr;
hr = CreateErrorInfo(&pcerrinfo);
hr = pcerrinfo->QueryInterface(IID_IErrorInfo, (LPVOID FAR*) &perrinfo);
if (SUCCEEDED(hr))
{
SetErrorInfo(0, perrinfo);
perrinfo->Release();
}
pcerrinfo->Release();