cerror.h
cerror_close
- Header
- cerror.h
- Prototype
- void __cdecl cerror_close(void);
- Description
- Removes a user supplied critical handler. The handler should have previously been installed by cerror_open().
- Compatibility
- DOS Windows 3.x Phar Lap DOSX Win32
- See Also
- cerror_open
- Example
- See cerror_open
cerror_open
- Header
- cerror.h
- Prototype
- void __cdecl cerror_open(void);
- Description
- Installs a user supplied critical handler. This function, which you must write, uses the following
prototype:
void __cdecl _cerror_handler(unsigned short *ax, unsigned short *di);
After a call to cerror_open, this routine begins receiving critical errors. It stops receiving them with a call to cerror_close.
Critical errors can occur under MS-DOS during attempts to access floppy disk drives or while using a parallel printer. They can cause the Abort, Retry, Ignore, Fail messages. Normally you have to write and debug a critical error handler for MS-DOS, and for each DOS extended platform you want to support.
The cerror_open and cerror_close functions provide a solution to this problem. They are portable across all platforms Digital Mars C++ supports.
- Compatibility
- DOS Windows 3.x Phar Lap DOSX Win32
- See Also
- cerror_close
- Example
/* Example for cerror_open, cerror_close */ #include <cerror.h> #include <stdio.h> #include <windows.h> static unsigned short ax_value, di_value; void _cerror_handler(unsigned short *ax, unsigned short *di) { ax_value = *ax; di_value = *di; } void main() { printf(" Be sure there is no disk in A:\n"); getch(); cerror_open(); ax_value = di_value = 0; fopen("a:anything", "r"); printf("After trying to open A:ANYTHING, ax = %x, di = %x\n", ax_value, di_value); ax_value = di_value = 0; fopen("c:anything", "r"); printf("After trying to open C:ANYTHING, ax = %x, di = %x\n", ax_value, di_value); cerror_close(); }
- Output
Be sure there is no disk in A: After trying to open A:ANYTHING, ax = 1a00, di = 2 After trying to open C:ANYTHING, ax = 0, di = 0