次の方法で共有


IMAPIProp::GetLastError

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 page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Returns a MAPIERROR structure that contains information about the previous error.

HRESULT GetLastError(
  HRESULT hResult,
  ULONG ulFlags,
  LPMAPIERROR FAR * lppMAPIError
);

Parameters

  • hResult
    [in] A handle to the error code generated in the previous method call.

  • ulFlags
    [in] A bitmask of flags that indicates the format for the text returned in the MAPIERROR structure pointed to by lppMAPIError. The following flag can be set:

    • MAPI_UNICODE
      The strings should be in Unicode format. If the MAPI_UNICODE flag is not set, the strings should be in ANSI format.
  • lppMAPIError
    [out] A pointer to a pointer to the MAPIERROR structure that contains version, component, and context information for the error. The lppMAPIError parameter can be set to NULL if there is no error information to return.

Return Value

  • S_OK
    The error information was returned.

  • MAPI_E_BAD_CHARWIDTH
    Either the MAPI_UNICODE flag was set and the implementation does not support Unicode, or MAPI_UNICODE was not set and the implementation supports only Unicode.

Remarks

The IMAPIProp::GetLastError method supplies information about a prior method call that failed. Clients can provide their users with detailed information about the error by including the data from the MAPIERROR structure in a dialog box.

All of the implementations of GetLastError provided by MAPI are ANSI implementations, except for the IAddrBook implementation. The GetLastError method included with IAddrBook supports Unicode.

Notes to Implementers

The details of a remote transport provider's implementation of this method and what messages this method returns are up to the transport provider, because the particular error conditions that lead to various HRESULT values will be different for different transport providers.

Notes to Callers

You can use the MAPIERROR structure pointed to by the lppMAPIError parameter, if GetLastError supplies one, only if the return value is S_OK. Sometimes GetLastError cannot determine what the last error was or has nothing more to report about the error. In this situation, a pointer to NULL is returned in lppMAPIError instead.

To release the memory for the MAPIERROR structure, call the MAPIFreeBuffer function.

For more information about the GetLastError method, see MAPI Extended Errors.

See Also

Reference

IAddrBook : IMAPIProp

MAPIERROR

MAPIFreeBuffer

IMAPIProp : IUnknown

Concepts

MAPI Extended Errors