This example uses WinGetErrorInfo to obtain detailed error information, assigns the error code, and frees the error block with WinFreeErrorInfo.
#define INCL_WINERRORS /* Window Error Functions */ #include <os2.h> BOOL fSuccess; /* success indicator */ ERRORID erridErrorCode;/* last error id code */ PERRINFO perriErrorInfo;/* error info structure */ HAB hab; /* anchor-block handle */ /* obtain error block */ perriErrorInfo = WinGetErrorInfo(hab); erridErrorCode = perriErrorInfo->idError; /* free error block */ fSuccess = WinFreeErrorInfo(perriErrorInfo);