--- os2sdk/demos/examples/dynlink/dynlink2.c 2018/08/09 12:25:13 1.1 +++ os2sdk/demos/examples/dynlink/dynlink2.c 2018/08/09 12:26:21 1.1.1.2 @@ -1,7 +1,7 @@ /* * dynlink2.c * - * Created 17 August 1987 by Kevin Ruddell, Microsoft Corp + * Created by Microsoft Corp. 1987 * * This example illustrates the use of run time dynamic linking. * A call to the procedure PRINTDATA is made in the dynamic link library DYNLIB. @@ -9,10 +9,15 @@ * NB - The DYNLIB.DLL file must be located in the LIBPATH specified in your * config.sys. You can place your current directory at the beginning * of the LIBPATH by saying libpath=.;c:\; etc. + * */ +#define INCL_DOSMODULEMGR +#define INCL_DOSPROCESS + +#include #include -#include +#include #define MODULE "DYNLIB" /* Name of dynamic link module */ #define PROCNAME "PRINTDATA" /* Name of routine in dynamic module */ @@ -22,7 +27,7 @@ main(argc, argv) int argc; char *argv[]; { - unsigned ModHdl; /* dynamic link module handle */ + HMODULE ModHdl; /* dynamic link module handle */ unsigned rc; /* return code */ char fbuf[FBSZ]; /* failure obj name buffer */ void (far pascal * DynamicProc)(); @@ -30,25 +35,25 @@ main(argc, argv) /* Load dynamic link module */ - if (rc = DOSLOADMODULE( fbuf, FBSZ, MODULE, &ModHdl)) + if (rc = DosLoadModule( fbuf, FBSZ, MODULE, &ModHdl)) { printf("module %s not found, failing obj %s error: %d\n", MODULE, fbuf, rc); - DOSEXIT(1,1); /* exit with error */ + DosExit(EXIT_PROCESS,1); /* exit with error */ } /* Get the address of procedure PROCNAME in the dynamic link module */ - if (rc = DOSGETPROCADDR( ModHdl, PROCNAME, - (unsigned long far *) &DynamicProc)) + if (rc = DosGetProcAddr( ModHdl, PROCNAME, + (PFN far *) &DynamicProc)) { printf("procedure %s not found, error: %d\n", PROCNAME, rc); - DOSEXIT(1,1); /* exit with error */ + DosExit(EXIT_PROCESS,1); /* exit with error */ } while(1) { (*DynamicProc)(); /* display shared and non-shared data */ - DOSSLEEP(100L); /* yield the processor */ + DosSleep(100L); /* yield the processor */ } }