How an Automation Component Returns an Error Object

When a component using Automation causes an error, it can return an object to describe that error. To do this, the component must do the following:

  1. Call CreateErrorInfo in the Automation DLL. This function creates an Automation error object that exposes ICreateErrorInfo and IErrorInfo.

  2. Call the methods in ICreateErrorInfo to store information in the error object, such as the string describing the error and the GUID of the interface that caused the error.

  3. Call QueryInterface to retrieve the IErrorInfo interface pointer on the error object. This interface pointer identifies the error object to all Automation components.

  4. Call SetErrorInfo in the Automation DLL and pass it the IErrorInfo interface pointer. This function replaces its current error object, if any, with the new error object and adds a reference count to the new error object.

  5. Call Release to release the ICreateErrorInfo and IErrorInfo interface pointers. This effectively transfers ownership of the error object from the component that caused the error to the Automation DLL.