This example uses WinGetLastError to obtain the error code corresponding to the last nonzero error for the specified anchor block. If only the error code is required, this function is preferable to the WinGetErrorInfo/WinFreeErrorInfo call sequence.
#define INCL_WINERRORS /* Window Error Functions */ #include <os2.h> ERRORID erridErrorCode;/* last error id code */ HAB hab; /* anchor-block handle */ /* get last nonzero error for this anchor block */ erridErrorCode = WinGetLastError(hab);