mmioGetLastError
The mmioGetLastError function retrieves the last error condition stored for a specific file handle. It is primarily used to gain more specific information when a previous MMIO function returns a generic error code like `MMIO_ERROR`.
Syntax
#define INCL_MMIOOS2 #include <os2.h> ULONG mmioGetLastError(HMMIO hmmio);
Parameters
Return Values
- rc (ULONG)
- Returns the last error code stored in the `ulErrorRet` field of the internal MMIOINFO structure for the specified handle.
- If the handle is invalid, the function returns MMIOERR_INVALID_HANDLE.
- If no error has occurred, it returns 0.
- Otherwise, it returns a specific MMIO error code or a standard OS/2 system error code.
Remarks
Many MMIO functions return a simple "Success" or "Failure" indicator. When a failure occurs (indicated by return codes such as `MMIO_ERROR` or `MMIO_CF_FAILURE`), mmioGetLastError can be called to pinpoint the exact cause.
The value returned is pulled directly from the `ulErrorRet` field of the MMIOINFO structure associated with the handle. This field is updated by the I/O procedure (IOProc) or the MMIO manager whenever an operation fails.
> [!NOTE] > The error code returned may be a multimedia-specific error (prefixed with `MMIOERR_`) or a general OS/2 kernel error code (such as `ERROR_DISK_FULL`).
Example Code
The following example demonstrates how to check for a detailed error after a generic failure:
HMMIO hmmio;
ULONG rc;
ULONG ulDetailedError;
/* ... perform some MMIO operation ... */
rc = mmioWrite(hmmio, pBuffer, ulSize);
if (rc == MMIO_ERROR) {
/* The write failed, get the specific reason */
ulDetailedError = mmioGetLastError(hmmio);
if (ulDetailedError == MMIOERR_WRITE_FAILED) {
/* Handle specific hardware write failure */
} else if (ulDetailedError == 29) { /* ERROR_WRITE_FAULT */
/* Handle OS/2 system error */
}
}