home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / advos2 / ch19 / cdll.c < prev    next >
Encoding:
Text File  |  1988-12-12  |  1.6 KB  |  60 lines

  1. /*
  2.     CDLL.C
  3.  
  4.     C source code for the dynlink library CDLL.LIB.  Requires
  5.     the module CINIT.ASM.
  6.  
  7.     Compile with:  C> cl /c /Asnu /Gs cdll.c
  8.     Assemble CINIT.ASM with:  C> masm /Mx cinit.asm;
  9.     Link with:  C> link /NOI /NOD cdll+cinit,cdll.dll,,os2,cdll
  10.     Create CDLL.LIB with:  C> implib cdll.lib cdll.def
  11.  
  12.     Copyright (C) 1988 Ray Duncan
  13. */
  14.  
  15. int _acrtused = 0;        /* don't link startup */
  16.  
  17. #define STDOUT 1            /* standard output handle */
  18.  
  19. #define API unsigned extern far pascal 
  20.  
  21. API DosWrite(unsigned, void far *, unsigned, unsigned far *);
  22.  
  23. static char funcmsg[] = "\nCDLL.MYFUNC is executing\n";
  24. static char initmsg[] = "\nCDLL.C_INIT is executing\n";
  25.  
  26.  
  27. /*
  28.     MYFUNC is exported for use by appliation programs;
  29.     it displays a message and returns the sum of 2 numbers.
  30. */
  31.  
  32. int far pascal MYFUNC(int a, int b)
  33. {
  34.     unsigned wlen;          /* receives length written */
  35.  
  36.                             /* display message that 
  37.                                MYFUNC is executing */
  38.     DosWrite(STDOUT,funcmsg,sizeof(funcmsg)-1,&wlen);
  39.     
  40.     return(a+b);            /* return function result */
  41. }
  42.  
  43.  
  44. /*
  45.     C_INIT is called from the entry point in CINIT.ASM when
  46.     a client process dynamically links to the library.
  47. */
  48.  
  49. int far pascal C_INIT(void)
  50. {
  51.     unsigned wlen;          /* receives length written */
  52.  
  53.                             /* display message that 
  54.                                C_INIT is executing */
  55.     DosWrite(STDOUT,initmsg,sizeof(initmsg)-1,&wlen);
  56.  
  57.     return(1);              /* return success code */
  58. }
  59. 
  60.