Annotation of os2sdk/demos/examples/dynlink/dynlink2.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * dynlink2.c
                      3:  *
                      4:  *     Created 17 August 1987 by Kevin Ruddell, Microsoft Corp
                      5:  *
                      6:  * This example illustrates the use of run time dynamic linking.
                      7:  * A call to the procedure PRINTDATA is made in the dynamic link library DYNLIB.
                      8:  *
                      9:  * NB - The DYNLIB.DLL file must be located in the LIBPATH specified in your
                     10:  *     config.sys.  You can place your current directory at the beginning
                     11:  *     of the LIBPATH by saying libpath=.;c:\; etc.
                     12:  */
                     13: 
                     14: #include <stdio.h>
                     15: #include <doscalls.h>
                     16: 
                     17: #define        MODULE          "DYNLIB"        /* Name of dynamic link module */
                     18: #define PROCNAME       "PRINTDATA"     /* Name of routine in dynamic module */
                     19: #define FBSZ           32              /* size of failure buffer */
                     20: 
                     21: main(argc, argv)
                     22:        int     argc;
                     23:        char    *argv[];
                     24: {
                     25:        unsigned        ModHdl;                 /* dynamic link module handle */
                     26:        unsigned        rc;                     /* return code */
                     27:        char            fbuf[FBSZ];             /* failure obj name buffer */
                     28:        void            (far pascal * DynamicProc)();
                     29: 
                     30: 
                     31:        /* Load dynamic link module */
                     32: 
                     33:        if (rc = DOSLOADMODULE( fbuf, FBSZ, MODULE, &ModHdl))
                     34:        {
                     35:                printf("module %s not found, failing obj %s error: %d\n",
                     36:                        MODULE, fbuf, rc);
                     37:                DOSEXIT(1,1);   /* exit with error */
                     38:        }
                     39:        
                     40:        /* Get the address of procedure PROCNAME in the dynamic link module */
                     41: 
                     42:        if (rc = DOSGETPROCADDR( ModHdl, PROCNAME,
                     43:                                 (unsigned long far *) &DynamicProc))
                     44:        {
                     45:                printf("procedure %s not found, error: %d\n", PROCNAME, rc);
                     46:                DOSEXIT(1,1);   /* exit with error */
                     47:        }
                     48: 
                     49:        while(1)
                     50:        {
                     51:                (*DynamicProc)();   /* display shared and non-shared data   */
                     52:                DOSSLEEP(100L);     /* yield the processor                */
                     53:        }
                     54: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.