Clarion - trabajar con dlls externas

 
Vista:

trabajar con dlls externas

Publicado por Lalo Meza (29 intervenciones) el 04/10/2006 22:02:24
Necesito trabajar con una dll externa , como la integro a una aplicacion en C55

Gracias por su ayuda
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:trabajar con dlls externas

Publicado por Joan (18 intervenciones) el 05/10/2006 00:15:45
You can use Windows .DLLs which have not been created with Clarion if you know the prototypes for the .DLL's procedures and functions. See the Programmer's Guide article on Multi-Language Programming for more information on this topic.
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.

Prototypes for any referenced .DLL procedures and functions must be in the CLARION program's MAP structure. Procedures and functions written in a language other than Clarion can still be referenced in a Clarion program by creating an equivalent Clarion prototype. The prototypes are placed in a MODULE structure which identifies the name of the DLL's library as the MODULE parameter. For example, if the DLL name is MY.DLL then the module structure would be:

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 .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.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

dlls externas RESUMIENDO

Publicado por Joan (18 intervenciones) el 05/10/2006 08:54:18
Resumiendo ejecuta C:\C55\Examples\SRC\LIBMAKER\LIBMAKER.EXE para fabricarte un .LIB de acceso a tu DLL que deberas incluir en el PROJECT de tu aplicacion para tener acceso a tu DLL.

Saludos Joan.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:trabajar con dlls externas

Publicado por Joan (18 intervenciones) el 05/10/2006 09:08:16
Mirate tambien el
c55\Examples\DLLTUTOR
como ejemplo de como usar DLL externas
C:\C55\Examples\DLLTUTOR

ejemplo de como declara las DLL dentro del codigo de clarion.
PROGRAM

INCLUDE('ABERROR.INC'),ONCE
INCLUDE('ABFILE.INC'),ONCE
INCLUDE('ABFUZZY.INC'),ONCE
INCLUDE('ABUTIL.INC'),ONCE
INCLUDE('EQUATES.CLW'),ONCE
INCLUDE('ERRORS.CLW'),ONCE
INCLUDE('KEYCODES.CLW'),ONCE

MAP
MODULE('REPORTS.DLL')
CustReport PROCEDURE,DLL !
InvoiceReport PROCEDURE,DLL !
END
MODULE('UPDATES.DLL')
CustInvoiceReport PROCEDURE,DLL !
ViewCustomers PROCEDURE,DLL !
ViewOrders PROCEDURE,DLL !
ViewProducts PROCEDURE,DLL !
END
!--- Application Global and Exported Procedure Definitions --------------------------------------------
MODULE('DLLTU001.CLW')
Main PROCEDURE !
END
MODULE('ALLFILES.DLL')
allfiles:Init PROCEDURE(<ErrorClass curGlobalErrors>, <INIClass curINIMgr>),DLL
allfiles:Kill PROCEDURE,DLL
END
MODULE('REPORTS.DLL')
reports:Init PROCEDURE(<ErrorClass curGlobalErrors>, <INIClass curINIMgr>),DLL
reports:Kill PROCEDURE,DLL
END
MODULE('UPDATES.DLL')
updates:Init PROCEDURE(<ErrorClass curGlobalErrors>, <INIClass curINIMgr>),DLL
updates:Kill PROCEDURE,DLL
END
END
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar