Jump to content

DosUnsetExceptionHandler: Difference between revisions

From EDM2
Created page with "==Description== Removes an exception handler from a thread's chain of exception handlers. ==Syntax== <PRE> #define INCL_DOSEXCEPTIONS #include <os2.h> PEXCEPTIONREGISTRATION..."
 
Ak120 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Description==
Removes an exception handler from a thread's chain of exception handlers.
Removes an exception handler from a thread's chain of exception handlers.


==Syntax==
==Syntax==
<PRE>
DosUnsetExceptionHandler(pERegRec)
#define INCL_DOSEXCEPTIONS
#include <os2.h>


PEXCEPTIONREGISTRATIONRECORD    pERegRec;  /*  A pointer to the exception registration record that describes the exception handler to be unregistered. */
APIRET                          ulrc;      /*  Return Code. */
ulrc = DosUnsetExceptionHandler(pERegRec);
</PRE>
==Parameters==
==Parameters==
; pERegRec (PEXCEPTIONREGISTRATIONRECORD) - input : A pointer to the exception registration record that describes the exception handler to be unregistered.
;pERegRec (PEXCEPTIONREGISTRATIONRECORD) - input : A pointer to the exception registration record that describes the exception handler to be unregistered.


==Return Code==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosUnsetExceptionHandler returns one of the following values:
* 0  NO_ERROR
* 87 ERROR_INVALID_PARAMETER


DosUnsetExceptionHandler returns one of the following values:
* 0  NO_ERROR
* 87 ERROR_INVALID_PARAMETER
==Remarks==
==Remarks==
Note: Do not make Presentation Manager calls from exception handlers.
Note: Do not make Presentation Manager calls from exception handlers.
Line 46: Line 35:
int main (VOID)
int main (VOID)
{
{
   EXCEPTIONREGISTRATIONRECORD RegRec  = {0};     /* Exception Registration Record */
   EXCEPTIONREGISTRATIONRECORD RegRec  = {0}; /* Exception Registration Record */
   APIRET      rc      = NO_ERROR;  /* Return code                  */
   APIRET      rc      = NO_ERROR;  /* Return code                  */


Line 96: Line 85:
   return XCPT_CONTINUE_SEARCH;          /* Exception not resolved... */
   return XCPT_CONTINUE_SEARCH;          /* Exception not resolved... */
}
}
</PRE>


</PRE>
==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosAcknowledgeSignalException|CPI:DosAcknowledgeSignalException]]
* [[DosAcknowledgeSignalException]]
* [[OS2 API:CPI:DosEnterMustComplete|CPI:DosEnterMustComplete]]
* [[DosEnterMustComplete]]
* [[OS2 API:CPI:DosExitMustComplete|CPI:DosExitMustComplete]]
* [[DosExitMustComplete]]
* [[OS2 API:CPI:DosRaiseException|CPI:DosRaiseException]]
* [[DosRaiseException]]
* [[OS2 API:CPI:DosSendSignalException|CPI:DosSendSignalException]]
* [[DosSendSignalException]]
* [[OS2 API:CPI:DosSetExceptionHandler|CPI:DosSetExceptionHandler]]
* [[DosSetExceptionHandler]]
* [[OS2 API:CPI:DosSetSignalExceptionFocus|CPI:DosSetSignalExceptionFocus]]
* [[DosSetSignalExceptionFocus]]
* [[OS2 API:CPI:DosUnwindException|CPI:DosUnwindException]]
* [[DosUnwindException]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 17:13, 8 March 2018

Removes an exception handler from a thread's chain of exception handlers.

Syntax

DosUnsetExceptionHandler(pERegRec)

Parameters

pERegRec (PEXCEPTIONREGISTRATIONRECORD) - input
A pointer to the exception registration record that describes the exception handler to be unregistered.

Return Code

ulrc (APIRET) - returns
DosUnsetExceptionHandler returns one of the following values:
  • 0 NO_ERROR
  • 87 ERROR_INVALID_PARAMETER

Remarks

Note: Do not make Presentation Manager calls from exception handlers.

DosUnsetExceptionHandler deregisters (removes) an exception handler from a thread's chain of registered exception handlers.

For a detailed list of the system exceptions, see System Exceptions.

Example Code

This example sets and unsets an exception handler named "MyTermhandler" from the thread's chain of exception handlers.

#define INCL_DOSPROCESS       /* DOS process values (for DosSleep) */
#define INCL_DOSEXCEPTIONS    /* DOS exception values */
#define INCL_ERRORS           /* DOS error values     */
#include <os2.h>
#include <stdio.h>

ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD       p1,
                             PEXCEPTIONREGISTRATIONRECORD p2,
                             PCONTEXTRECORD               p3,
                             PVOID                        pv );

int main (VOID)
{
  EXCEPTIONREGISTRATIONRECORD RegRec  = {0};  /* Exception Registration Record */
  APIRET      rc      = NO_ERROR;   /* Return code                   */

  /* Add MyTermHandler to this thread's chain of exception handlers */

  RegRec.ExceptionHandler = (ERR)MyTermHandler;
  rc = DosSetExceptionHandler( &RegRec );
  if (rc != NO_ERROR) {
     printf("DosSetExceptionHandler error: return code = %u\n",rc);
     return 1;
  }

  printf("Terminate this program using Ctrl-C or Ctrl-Break.\n");

  rc = DosSleep(60000L);   /* Give user plenty of time to comply... */

  rc = DosUnsetExceptionHandler( &RegRec );
  if (rc != NO_ERROR) {
     printf("DosUnsetExceptionHandler error: return code = %u\n",rc);
     return 1;
  }
  return NO_ERROR;
}
/***************************************************************************/
ULONG _System MyTermHandler( PEXCEPTIONREPORTRECORD       p1,
                             PEXCEPTIONREGISTRATIONRECORD p2,
                             PCONTEXTRECORD               p3,
                             PVOID                        pv )
{
  printf("*** MyTermHandler entered: ExceptionNum = %x\n",p1->ExceptionNum);

  switch( p1->ExceptionNum) {
   case XCPT_SIGNAL: {
      printf(" XCPT_SIGNAL");
      switch( p1->ExceptionInfo[0] ) {
        case XCPT_SIGNAL_INTR:     { printf("_INTR"); break; }
        case XCPT_SIGNAL_KILLPROC: { printf("_KILLPROC"); break; }
        case XCPT_SIGNAL_BREAK:    { printf("_BREAK"); break; }
        default:;
      }
      printf("\n"); break;
   }
   case XCPT_PROCESS_TERMINATE:       { printf(" Process Terminate \n"); break;}
   case XCPT_ASYNC_PROCESS_TERMINATE: { printf(" Async Process Term\n"); break;}
   case XCPT_UNWIND:                  { printf(" XCPT_UNWIND\n");        break;}
   default:;
  }

  return XCPT_CONTINUE_SEARCH;          /* Exception not resolved... */
}

Related Functions