home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c045 / 5.ddi / CALC / CALCFUNC.C$ / CALCFUNC.bin
Encoding:
Text File  |  1992-01-01  |  2.3 KB  |  84 lines

  1. /****************************************************************************
  2.  
  3.     PROGRAM: CalcFunc.c
  4.  
  5.     PURPOSE: Demonstrates the use of a DLL by a Visual Basic application "CALC"
  6.  
  7.     FUNCTIONS:
  8.  
  9.         LibMain() - In this example, no initialization tasks are required.
  10.         AddTwo() - Takes two longs and returns their sum
  11.         SubTwo() - Takes two longs and returns their difference
  12.         MultTwo() - Takes two longs and returns their product
  13.         DivTwo() - Takes two longs and returns their quotient
  14.  
  15.     COMMENTS:
  16.  
  17.         Please see the Globals section of the Visual Basic "Calc" example
  18.         for the declaration of these functions.  Also notice that the
  19.         Calling Program (VB.EXE) is specified in the Run/Debug dialog box
  20.         on the Options menu of QC/Win.
  21.  
  22.         A WEP is provided by the C runtime libraries.  See the CALCFUNC.DEF
  23.         file for the appropriate linker instructions to export the WEP.
  24.  
  25. ****************************************************************************/
  26.  
  27. #include <windows.h>
  28.  
  29. /*****************************************************************************
  30.     FUNCTION: LibMain(HANDLE, WORD, WORD, LPSTR)
  31.  
  32.     PURPOSE:
  33.         Is called by Windows when the DLL is loaded.
  34.  
  35.         The LibMain function should perform any initialization tasks
  36.         required by the DLL.  In this example, no initialization
  37.         tasks are required.  LibMain should return a value of 1 if
  38.         the initialization is successful.
  39.  
  40. *******************************************************************************/
  41.  
  42. int FAR PASCAL LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
  43. {
  44.     return TRUE;
  45. }
  46.  
  47. /****************************************************************************
  48.  
  49.     FUNCTIONS:
  50.         AddTwo (long, long)
  51.         SubTwo (long, long)
  52.         MultTwo(long, long)
  53.         DivTwo (long, long)
  54.  
  55.     PURPOSE:
  56.         Called by the Visual Basic sample "Calc".  Returns the result as a
  57.         long.
  58.  
  59.     COMMENTS:
  60.         The values passed in and returned by the DLL functions must be
  61.         defined in the Visual Basic sample as "By Val".
  62.  
  63. ****************************************************************************/
  64.  
  65. long FAR PASCAL AddTwo(long One, long Two)
  66. {
  67.     return (One+Two);
  68. }
  69.  
  70. long FAR PASCAL SubTwo(long One, long Two)
  71. {
  72.     return (One-Two);
  73. }
  74.  
  75. long FAR PASCAL MultTwo(long One, long Two)
  76. {
  77.     return (One*Two);
  78. }
  79.  
  80. long FAR PASCAL DivTwo(long One, long Two)
  81. {
  82.     return (One/Two);
  83. }
  84.