COM Library Error-Related Macros and Functions

The following macros and functions are defined in the COM Library include files to manipulate status code values.


#define SEVERITY_SUCCESS      0
#define SEVERITY_ERROR         1

#define SUCCEEDED(Status)         ((HRESULT)(Status) >= 0)
#define FAILED(Status)            ((HRESULT)(Status)<0)

#define HRESULT_CODE(hr)          ((hr) & 0xFFFF)
#define HRESULT_FACILITY(hr)        (((hr) >> 16) & 0x1fff)
#define HRESULT_SEVERITY(hr)        (((hr) >> 31) & 0x1)

#define MAKE_HRESULT(sev,fac,code) \
   ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )