_dosexterr

Description

Gets register values returned by 0x59.

#include <dos.h>

int _dosexterr( struct _DOSERROR *errorinfo );

errorinfo Extended DOS error information  

Remarks

The _dosexterr function obtains the extended error information returned by DOS system call 0x59 and stores the values in the structure pointed to by errorinfo. This function is useful when making system calls with DOS versions 3.0 or later, which offer extended error handling.

The structure type _DOSERROR is defined in DOS.H. The _DOSERROR structure contains the following elements:

Element Description

int exterror AX register contents
char errclass BH register contents
char action BL register contents
char locus CH register contents

Giving a NULL pointer argument causes _dosexterr to return the value in AX without filling in the structure fields. See MS-DOS Encyclopedia (Duncan, ed.; Redmond, WA: Microsoft Press, 1988) or Programmer's PC Sourcebook 2nd ed. (Hogan; Redmond, WA: Microsoft Press, 1991) for more information on the register contents.

Return Value

The _dosexterr function returns the value in the AX register (identical to the value in the exterror structure field).

Compatibility

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:None

The _dosexterr function should be used only with DOS versions 3.0 or later.

See Also

perror

Example

/* DOSEXERR.C: This program tries to open the file test.dat.

* If the attempted open operation fails, the program uses

* _dosexterr to display extended error information.

*/

#include <dos.h>

#include <io.h>

#include <fcntl.h>

#include <stdio.h>

void main( void )

{

struct _DOSERROR doserror;

int fd;

/* Attempt to open a non-existent file */

if( (fd = _open( "NOSUCHF.ILE", _O_RDONLY )) == -1 )

{

_dosexterr( &doserror );

printf( "Error: %d Errclass: %d Action: %d Locus: %d\n",

doserror.exterror, doserror.errclass,

doserror.action, doserror.locus );

}

else

{

printf( "Open succeeded so no extended information printed\n" );

_close( fd );

}

}

Output

Error: 2 Errclass: 8 Action: 3 Locus: 2