home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
-
- PROGRAM: CalcFunc.c
-
- PURPOSE: Demonstrates the use of a DLL by a Visual Basic application "CALC"
-
- FUNCTIONS:
-
- LibMain() - In this example, no initialization tasks are required.
- AddTwo() - Takes two longs and returns their sum
- SubTwo() - Takes two longs and returns their difference
- MultTwo() - Takes two longs and returns their product
- DivTwo() - Takes two longs and returns their quotient
-
- COMMENTS:
-
- Please see the Globals section of the Visual Basic "Calc" example
- for the declaration of these functions. Also notice that the
- Calling Program (VB.EXE) is specified in the Run/Debug dialog box
- on the Options menu of QC/Win.
-
- A WEP is provided by the C runtime libraries. See the CALCFUNC.DEF
- file for the appropriate linker instructions to export the WEP.
-
- ****************************************************************************/
-
- #include <windows.h>
-
- /*****************************************************************************
- FUNCTION: LibMain(HANDLE, WORD, WORD, LPSTR)
-
- PURPOSE:
- Is called by Windows when the DLL is loaded.
-
- The LibMain function should perform any initialization tasks
- required by the DLL. In this example, no initialization
- tasks are required. LibMain should return a value of 1 if
- the initialization is successful.
-
- *******************************************************************************/
-
- int FAR PASCAL LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
- {
- return TRUE;
- }
-
- /****************************************************************************
-
- FUNCTIONS:
- AddTwo (long, long)
- SubTwo (long, long)
- MultTwo(long, long)
- DivTwo (long, long)
-
- PURPOSE:
- Called by the Visual Basic sample "Calc". Returns the result as a
- long.
-
- COMMENTS:
- The values passed in and returned by the DLL functions must be
- defined in the Visual Basic sample as "By Val".
-
- ****************************************************************************/
-
- long FAR PASCAL AddTwo(long One, long Two)
- {
- return (One+Two);
- }
-
- long FAR PASCAL SubTwo(long One, long Two)
- {
- return (One-Two);
- }
-
- long FAR PASCAL MultTwo(long One, long Two)
- {
- return (One*Two);
- }
-
- long FAR PASCAL DivTwo(long One, long Two)
- {
- return (One/Two);
- }
-