Using Windows DLLs not Created in Clarion
Using Windows DLLs NOT Created in Clarion If the source language prototypes are known, then equivalent Clarion prototypes must be created and included in a CLARION program's MAP for all referenced DLL procedures and functions. Also, Clarion requires a Library (.LIB) file in the Project Tree under Library and Object files. This Library file entry enables the linker to resolve the procedure and function references in the .DLL.
If you have a Windows DLL (not created with Clarion) that you want to use in a CLARION program, then the following steps are required to enable the CLARION program to access the DLL's procedures and functions: Create Equivalent Clarion Language Prototypes. Create a Clarion Library (.LIB ) File for the DLL. Reference the Library (.LIB) File in the Project System. Create Equivalent Clarion Language Prototypes. MODULE('MY.LIB') There are several issues to consider when creating equivalent prototypes in Clarion which are dependent upon a DLL's source code language. A primary consideration is relating equivalent data types in the other language to Clarion. Equivalent data types can be determined by considering the "underlying" machine data type represented by each language data type. For example, the CLARION Language Reference identifies the Clarion data type SREAL as a "four-byte signed floating point". The following is an example of C and C++ code data type equivalents. unsigned char ==> BYTE short ==> SHORT unsigned short ==> USHORT long ==> LONG unsigned long ==> ULONG float ==> SREAL double ==> REAL A Clarion GROUP is roughly equivalent to a C or C++ struct. For example: Struct1 GROUP ! Struct1 is defined as a GROUP ul1 ULONG ! containing two ULONG values ul2 ULONG END This form of definition reserves space for Struct1 and is equivalent to the C definition: struct { unsigned long ul1; unsigned long ul2; } Struct1; A second important prototyping consideration is the procedure/ function calling convention utilized by another language. Clarion provides support for three different calling conventions: PASCAL, C, and TopSpeed's Register Based. Create a Clarion Library .LIB File for the DLL. You can create a .LIB file for the DLL using the LIBMAKER.EXE utility program that comes with Clarion as one of the example programs. Simply run the program, select the .DLL and have it automatically create the TopSpeed format .LIB file for you. Reference the .LIB File in the Project System. You must place the Library (.LIB) file in the Project Tree under Library and Object files for any Project that will use the .DLL. |

