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 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 QueryInterfaceon ICreateErrorInfoto set its contents. You can then pass the resulting object to SetErrorInfo.

The generic error object implements both ICreateErrorInfoand IErrorInfo.

Example

The following example code shows how to use the CreateErrorInfofunction.

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 *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