Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All


Windows Mobile 6.5
A version of this page is also available for

This function creates an instance of a generic error object.

HRESULT CreateErrorInfo(
  ICreateErrorInfo** pperrinfo 


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

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

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.

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;
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);

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

Windows Embedded CEWindows CE 2.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

© 2015 Microsoft