pero al ejecutarlo da gpf, aparte tengo una duda, con respecto a
aparte, de que si el enfoque de programacion y la tecnica es la correcta, son mis primeros pinitos en esto.
a esos guru de c con harbour, please una ayudita.
gracias.-
...
#define tEXTERNAL_NUMERIC unsigned long /*POR QUE ACA*/
...
typedef struct
{
tTYPE_TRANSL_FUNC TypeTranslFuncPtr;
LPVOID ParamValuePtr;
} tEXTERNAL_NUMERIC; /*SI YA ESTA ACA*/
- Code: Select all Expand view RUN
PROCEDURE Main()
?"Begin Test..."
?"Open Port...:", MYTSL_PortOpen( "COM1", 9600 )
?"Lines.......:", MYTSL_LBTRSHDR(1)
?"N/D.........:", MYTSL_LBTRSLN( { 1, 1, "Not Defined", 2, "A", 10.5, 21, 0 } )
?"Close Port..:", MYTSL_PortClose()
RETURN
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
#include "hbapiitm.h"
#define BYTE unsigned char
#define tEXTERNAL_NUMERIC unsigned long
#define SOK 0
#define SERROR -1
#define DLL_NAME "thermalservicelibrary.dll"
typedef int ( *tTYPE_TRANSL_FUNC )( LPVOID, char * );
typedef struct
{
tTYPE_TRANSL_FUNC TypeTranslFuncPtr;
LPVOID ParamValuePtr;
} tEXTERNAL_NUMERIC;
typedef struct
{
BYTE Pi;
BYTE Pr;
char * Name;
tEXTERNAL_NUMERIC Quantity;
char Vat;
tEXTERNAL_NUMERIC Price;
tEXTERNAL_NUMERIC Gross;
tEXTERNAL_NUMERIC Discount;
} tLBTRSLN_PARAMS;
HINSTANCE hDllHandle = 0;
typedef LONG (WINAPI *TSL_OPEN)(LPSTR szComPuerto, USHORT usBaudRate);
typedef LONG (WINAPI *TSL_CLOSE)(VOID);
typedef LONG (WINAPI *TSL_LBTRSHDR)(USHORT usNumLine);
typedef LONG (WINAPI *TSL_LBTREXITCAN)(LPSTR szParam1, LPSTR szParam2);
typedef LONG (WINAPI *TSL_LBTRSLN)(tLBTRSLN_PARAMS aSLN_Par);
typedef LONG (WINAPI *TSL_LBCASREP)(VOID);
HB_FUNC( MYTSL_PORTOPEN )
{
LPSTR szComPort = (char *) hb_parc( 1 );
USHORT usBaudRate = hb_parni( 2 );
SHORT sReturn;
hDllHandle = LoadLibrary( DLL_NAME );
if( hDllHandle )
{
TSL_OPEN pFunc = (TSL_OPEN) GetProcAddress( hDllHandle, "p_Port_Open" );
if( pFunc )
{
sReturn = pFunc( szComPort, usBaudRate );
if( sReturn == SERROR )
{
FreeLibrary( hDllHandle );
}
hb_retni( sReturn );
return;
}
}
hb_retni( SERROR );
}
HB_FUNC( MYTSL_PORTCLOSE )
{
if( hDllHandle )
{
TSL_CLOSE pFunc = (TSL_CLOSE) GetProcAddress( hDllHandle, "p_Port_Close" );
if( pFunc )
{
hb_retni( pFunc() );
FreeLibrary( hDllHandle );
return;
}
}
hb_retni( SERROR );
}
HB_FUNC( MYTSL_LBTRSHDR )
{
USHORT usNumLine = (SHORT) hb_parni( 1 );
if( hDllHandle )
{
if( usNumLine >= 1 && usNumLine <= 80 )
{
TSL_LBTRSHDR pFunc = (TSL_LBTRSHDR) GetProcAddress( hDllHandle, "p_LBTRSHDR" );
if( pFunc )
{
hb_retni( pFunc( usNumLine ) );
return;
}
}
}
hb_retni( SERROR );
}
HB_FUNC( MYTSL_LBTREXITCAN )
{
LPSTR szParam1 = (char *) hb_parc(1);
LPSTR szParam2 = (char *) hb_parc(2);
if( hDllHandle )
{
TSL_LBTREXITCAN pFunc = (TSL_LBTREXITCAN) GetProcAddress( hDllHandle, "p_LBTREXITCAN" );
if( pFunc )
{
hb_retni( pFunc( szParam1, szParam2 ) );
return;
}
}
hb_retni( SERROR );
}
HB_FUNC( MYTSL_LBTRSLN )
{
tLBTRSLN_PARAMS aSLN_Par;
aSLN_Par.Pi = (BYTE) hb_parvni( 1, 1 );
aSLN_Par.Pr = (BYTE) hb_parvni( 1, 2 );
aSLN_Par.Name = (LPSTR) hb_parvc( 1, 3 );
aSLN_Par.Quantity = (tEXTERNAL_NUMERIC) hb_parvnd( 1, 4 );
aSLN_Par.Vat = (char) hb_parvc( 1, 5 );
aSLN_Par.Price = (tEXTERNAL_NUMERIC) hb_parvnd( 1, 6 );
aSLN_Par.Gross = (tEXTERNAL_NUMERIC) hb_parvnd( 1, 7 );
aSLN_Par.Discount = (tEXTERNAL_NUMERIC) hb_parvnd( 1, 8 );
if( hDllHandle )
{
TSL_LBTRSLN pFunc = (TSL_LBTRSLN) GetProcAddress( hDllHandle, "p_LBTRSLN" );
if( pFunc )
{
hb_retni( pFunc( aSLN_Par ) );
return;
}
}
hb_retni( SERROR );
}
HB_FUNC( MYTSL_LBCASREP )
{
if( hDllHandle )
{
TSL_LBCASREP pFunc = (TSL_LBCASREP) GetProcAddress( hDllHandle, "p_LBCASREP" );
if( pFunc )
{
hb_retni( pFunc() );
return;
}
}
hb_retni( SERROR );
}
#pragma ENDDUMP