--- os2sdk/demos/examples/setvec/setvec.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/examples/setvec/setvec.c 2018/08/09 12:26:22 1.1.1.2 @@ -1,5 +1,5 @@ /* - * Example of DOSSETVEC usage + * Example of DosSetVec usage * * This call allows a process to register a handler for the 80286 * exception vectors. This program works Family API. @@ -36,41 +36,45 @@ * * Compile as: cl -AL -G2 -Gs -Lp setvec.c * - * Copyright (C) Microsoft Corp. 1986 + * Created by Microsoft Corp. 1986 */ -#include +#define INCL_DOSMISC + +#include +#include int j = 0; /* zero variable for division */ main() { - unsigned int VecNum; /* Exception number (0,4,5,6,7,16) */ - void (*PrevAddress)(); /* Storage for old vector address, used to reset - the vector when finished */ - void (*Dummy)(); /* Dummy variable used when resetting vector */ - void handler(); /* Name of routine that will handle exception */ + USHORT VecNum; /* Exception number (0,4,5,6,7,16) */ + PFN PrevAddress; /* Storage for old vector address, used to + + reset the vector when finished */ + PFN Dummy; /* Dummy variable used when resetting vector */ + int APIENTRY handler(); /* Name of routine that will handle exception */ int i = 9; /* Variable to be divided by 0 */ /* Set up handler for Exception 0, 'divide by zero' */ VecNum = 0; - DOSSETVEC(VecNum,handler,&PrevAddress); + DosSetVec(VecNum,handler,&PrevAddress); /* Test the handler */ i = i/j; printf("new i = %d\n", i); /* Reset handler for exception 0 */ - DOSSETVEC(VecNum,PrevAddress,&Dummy); + DosSetVec(VecNum,PrevAddress,&Dummy); } /* - * Handler subroutine for testing DOSSETVEC above. + * Handler subroutine for testing DosSetVec above. * This is the routine that will get control * when the exception occurs. */ -void handler() +int APIENTRY handler() { j = 3; /* Since j=0 caused this exception, setting j=3 will prevent the exception from recurring, when we return */