CreateErrorInfo

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function creates an instance of a generic error object.

Syntax

HRESULT CreateErrorInfo(
  ICreateErrorInfo** pperrinfo 
); 

Parameters

  • pperrinfo
    [in] Pointer to a pointer to a system-implemented generic error object that supports ICreateErrorInfo.

Return Value

If successful, the function returns the HRESULT value S_OK. If it could not create the error object, the function returns E_OUTOFMEMORY.

Remarks

This function retrieves a pointer to a generic error object, which you can use with QueryInterface on ICreateErrorInfo to set its contents. You can then pass the resulting object to SetErrorInfo.

The generic error object implements both ICreateErrorInfo and IErrorInfo.

Example

The following example code shows how to use the CreateErrorInfo function.

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

ICreateErrorInfo *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();

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

Requirements

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

See Also

Reference

Automation Functions
SetErrorInfo
DispInvoke