System.HResult

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

type HResult = Integer;

C++

typedef HRESULT              HResult;          //

Properties

Type Visibility Source Unit Parent
type
typedef
public
System.pas
sysmac.h
System System

Description

HResult is the return type for functions that return an error code.

Many functions return an HResult value to indicate the success or failure of an operation. This data type was originally defined for the Win32 platform, but is now used by many different APIs running on a variety of platforms. The precise usage of HResult values varies from API to API, but certain basic conventions are usually followed.

An HResult value has 32 bits and consists of the following fields (starting from the high-order bit):

  • A one-bit Severity field. The Severity bit is 1 if a fatal error occurred, 0 otherwise.
  • A 4-bit field that is not used.
  • An 11-bit Facility Code, indicating the general nature of the HResult value. General purpose HResult values have a Facility Code of 0.
  • A 16-bit Error Code, indicating the specific error. An Error Code of 0 indicates no error.

The following table lists the values of the HResult type:

Constant Hex. Value Meaning

S_OK

0

No error. In some APIs, S_OK indicates a successful operation with a return value of True.

S_FALSE

$00000001

No error, but the operation did not produce a useful result. In some APIs, S_FALSE indicates a successful operation with a return value of False.

E_NOINTERFACE

$80004002

Interface not supported.

E_UNEXPECTED

$8000FFFF

Catastrophic failure.

E_NOTIMPL

$80004001

Operation not implemented.

Note that in the above constant names, the S_ and E_ prefixes correspond to the value of the Severity bit.