Page 1 of 1

convert C to fivewin

Posted: Mon May 22, 2017 4:21 pm
by vensanto
I need to utilize the functions of CEFDLL.DLL into my fivewin program

first i have run
IMPLIB cefdll.lib CEFDLL.DLL
for creating the cefdll.lib

now i need to convert the follow C function for fivewin:

DWORD CEFOpen (int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError)

DWORD CEFOpenEth (LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError)

DWORD CEFOpenUSB (LPTSTR strPrinterName, LPDWORD lpdwSysError)

DWORD CEFWrite (unsigned char *lpCommand, LPDWORD lpdwSysError)

DWORD CEFClose (LPDWORD lpdwSysError)

DWORD CEFRead (unsigned char *lpMemArea, LPDWORD pdwByteRead, LPDWORD lpdwSysError)

DWORD CEFGetVersion (LPTSTR lpVer, LPDWORD lpdwSysError)

DWORD CEFOpenUnSafe (int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError)

DWORD CEFOpenEthUnSafe(LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError)

DWORD CEFOpenUSBUnSafe(LPTSTR strPrinterName, LPDWORD lpdwSysError)

please help me

thanks

Re: convert C to fivewin

Posted: Mon May 22, 2017 5:03 pm
by Antonio Linares
// DWORD CEFOpen (int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError)

HB_FUNC( CEFOPEN )
{
DWORD dwSysError;

hb_retnl( CEFOpen( hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ), hb_parnl( 5 ), hb_parnl( 6 ), &dwSysError ) );
}

Re: convert C to fivewin

Posted: Tue May 23, 2017 5:45 am
by vensanto
Dear Antonio,
thanks but now i get this error

Compiling: SA.HBP...
Compiling 'SA.PRG'...
Warning W8065 SA.PRG 53: Call to function 'CEFOpen' with no prototype in function HB_FUN_CEFOPEN
Error: Unresolved external '_CEFOpen' referenced from C:\USERS\SANTO\APPDATA\LOCAL\TEMP\HBMK_VE2YOI.DIR\SA.OBJ
Error: Unable to perform link
hbmk2[SA]: Error: Running linker. 2
1 Files, 1 Warnings, 3 Errors
Compile time: 1.26s Link time: 0s Total time: 1.26s


this is the documentation syntax

DWORD CEFOpen (int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError)

[Description]
Open communication port and set parameters for serial communication.

[Parameters]
intCom : serial communication port number;
dwBaudRate : baud rate;
byParity : parity;
byDataBit : data bits;
byStopBit : stop bits;
byFlowControl : fl ow control;
lpdwSysError : system error returned.

thanks

Re: convert C to fivewin

Posted: Tue May 23, 2017 8:21 am
by Antonio Linares
Are you linking cefdll.lib ?

You have to link it

Re: convert C to fivewin

Posted: Tue May 23, 2017 3:29 pm
by vensanto
I have linked the cefdll.lib
but i get always the errror

Warning W8065 SA.PRG 53: Call to function 'CEFOpen' with no prototype in function HB_FUN_CEFOPEN
Error: Unresolved external '_CEFOpen' referenced from C:\USERS\SANTO\APPDATA\LOCAL\TEMP\HBMK_VE2YOI.DIR\SA.OBJ

thanks

Re: convert C to fivewin

Posted: Tue May 23, 2017 3:38 pm
by cnavarro
You do not have any file with extension .H ( for #include " .H" )

Re: convert C to fivewin

Posted: Tue May 23, 2017 5:18 pm
by vensanto
I do not have any file .H

the cefdll.dll is a dll for a cash register CUSTOM XKUBE

you can download from the follow link:
www.veneziasoft.com/download/custom/cefdll125.zip

there is any samples in the zip file
but i dont know how interface it with fivewin

thanks for you help

Re: convert C to fivewin

Posted: Tue May 23, 2017 5:22 pm
by cnavarro
Ok, try putting these lines at the beginning of the .C file, after the includes

Code: Select all

DWORD CEFOpen (int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError);
DWORD CEFOpenEth (LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError);
DWORD CEFOpenUSB (LPTSTR strPrinterName, LPDWORD lpdwSysError);
DWORD CEFWrite (unsigned char *lpCommand, LPDWORD lpdwSysError);
DWORD CEFClose (LPDWORD lpdwSysError);
DWORD CEFRead (unsigned char *lpMemArea, LPDWORD pdwByteRead, LPDWORD lpdwSysError);
DWORD CEFGetVersion (LPTSTR lpVer, LPDWORD lpdwSysError);
DWORD CEFOpenUnSafe (int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError);
DWORD CEFOpenEthUnSafe(LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError);
DWORD CEFOpenUSBUnSafe(LPTSTR strPrinterName, LPDWORD lpdwSysError);
 
---------------------------------- EDITED -------------------------------
I forgot to put ";" At the end of each line

Re: convert C to fivewin

Posted: Wed May 24, 2017 1:42 pm
by vensanto
hello i try but i get error

any sample please

thanks

Re: convert C to fivewin

Posted: Wed May 24, 2017 6:11 pm
by vensanto
the problem is IMPLIB without -a
now it's ok

here the code:
thanks to all

===

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

DWORD CEFGetVersion(LPTSTR lpVer, LPDWORD lpdwSysError);

DWORD CEFRead(unsigned char *lpMemArea, LPDWORD pdwByteRead, LPDWORD lpdwSysError);
DWORD CEFWrite(unsigned char *lpCommand, LPDWORD lpdwSysError);
DWORD CEFClose(LPDWORD lpdwSysError);

DWORD CEFOpen(int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError);
DWORD CEFOpenEth(LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError);
DWORD CEFOpenUSB(LPTSTR strPrinterName, LPDWORD lpdwSysError);

DWORD CEFOpenUnSafe(int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError);
DWORD CEFOpenEthUnSafe(LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError);
DWORD CEFOpenUSBUnSafe(LPTSTR strPrinterName, LPDWORD lpdwSysError);



// DWORD CEFGetVersion(LPTSTR lpVer, LPDWORD lpdwSysError);
HB_FUNC( CEFVERSION )
{
DWORD dwSysError;

hb_retnl( CEFGetVersion( (LPSTR)hb_parc(1) , &dwSysError ) );
}



// DWORD CEFRead(unsigned char *lpMemArea, LPDWORD pdwByteRead, LPDWORD lpdwSysError);
HB_FUNC( CEFREAD )
{
DWORD dwSysError;

hb_retnl( CEFRead( (LPBYTE)hb_parc(1) , (LPDWORD)hb_parc(2) , &dwSysError ) );
}



// DWORD CEFWrite(unsigned char *lpCommand, LPDWORD lpdwSysError);
HB_FUNC( CEFWRITE )
{
DWORD dwSysError;

hb_retnl( CEFWrite( (LPBYTE)hb_parc(1) , &dwSysError ) );
}



// DWORD CEFClose(LPDWORD lpdwSysError);
HB_FUNC( CEFCLOSE )
{
DWORD dwSysError;

hb_retnl( CEFClose( &dwSysError ) );
}



// DWORD CEFOpen(int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError);
HB_FUNC( CEFOPEN )
{
DWORD dwSysError;

hb_retnl( CEFOpen( hb_parnl(1) , hb_parnl(2) , hb_parnl(3) , hb_parnl(4) , hb_parnl(5), hb_parnl(6) , &dwSysError ) );
}



// DWORD CEFOpenEth(LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError);
HB_FUNC( CEFOPENETH )
{
LPSTR strIp = (LPSTR) hb_parc(1);
DWORD dwSysError;

hb_retnl( CEFOpenEth( strIp , hb_parnl(2) , &dwSysError ) );
}



// DWORD CEFOpenUSB(LPTSTR strPrinterName, LPDWORD lpdwSysError);
HB_FUNC( CEFOPENUSB )
{
LPSTR strPrinterName = (LPSTR) hb_parc(1);
DWORD dwSysError;

hb_retnl( CEFOpenUSB( strPrinterName , &dwSysError ) );
}



// DWORD CEFOpenUnSafe(int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError);
HB_FUNC( CEFOPENUNSAFE )
{
DWORD dwSysError;

hb_retnl( CEFOpenUnSafe( hb_parnl(1) , hb_parnl(2) , hb_parnl(3) , hb_parnl(4) , hb_parnl(5), hb_parnl(6) , &dwSysError ) );
}



// DWORD CEFOpenEthUnSafe(LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError);
HB_FUNC( CEFOPENETHUNSAFE )
{
LPSTR strIp = (LPSTR) hb_parc(1);
DWORD dwSysError;

hb_retnl( CEFOpenEthUnSafe( strIp , hb_parnl(2) , &dwSysError ) );
}



// DWORD CEFOpenUSBUnSafe(LPTSTR strPrinterName, LPDWORD lpdwSysError);
HB_FUNC( CEFOPENUSBUNSAFE )
{
LPSTR strPrinterName = (LPSTR) hb_parc(1);
DWORD dwSysError;

hb_retnl( CEFOpenUSBUnSafe( strPrinterName , &dwSysError ) );
}


#pragma ENDDUMP

Re: convert C to fivewin

Posted: Wed May 24, 2017 6:13 pm
by cnavarro
Great

Re: convert C to fivewin

Posted: Thu May 25, 2017 7:29 am
by Antonio Linares
IMO, this should be this way:

// DWORD CEFRead(unsigned char *lpMemArea, LPDWORD pdwByteRead, LPDWORD lpdwSysError);
HB_FUNC( CEFREAD )
{
DWORD dwByteRead, dwSysError;

hb_retnl( CEFRead( ( LPBYTE ) hb_parnl(1) , &dwByteRead, &dwSysError ) );
}

Re: convert C to fivewin

Posted: Thu May 25, 2017 7:32 am
by Antonio Linares
As all functions use DWORD dwSysError; you could use a static variable:

static DWORD dwSysError;

and remove it from all functions. Next you can implement a function to retrieve its value:

Code: Select all

HB_FUNC( CEF_GETSYSERROR )
{
   hb_retnl( dwSysError );
}

Re: convert C to fivewin

Posted: Thu May 25, 2017 1:03 pm
by vensanto
Thank You Antonio

Re: convert C to fivewin

Posted: Thu May 25, 2017 1:12 pm
by vensanto
now it's better
here the new code:


#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

static DWORD dwSysError;


DWORD CEFGetVersion(LPTSTR lpVer, LPDWORD lpdwSysError);

DWORD CEFRead(unsigned char *lpMemArea, LPDWORD pdwByteRead, LPDWORD lpdwSysError);
DWORD CEFWrite(unsigned char *lpCommand, LPDWORD lpdwSysError);
DWORD CEFClose(LPDWORD lpdwSysError);

DWORD CEFOpen(int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError);
DWORD CEFOpenEth(LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError);
DWORD CEFOpenUSB(LPTSTR strPrinterName, LPDWORD lpdwSysError);

DWORD CEFOpenUnSafe(int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError);
DWORD CEFOpenEthUnSafe(LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError);
DWORD CEFOpenUSBUnSafe(LPTSTR strPrinterName, LPDWORD lpdwSysError);


HB_FUNC( CEF_GETSYSERROR )
{
hb_retnl( dwSysError );
}


// DWORD CEFGetVersion(LPTSTR lpVer, LPDWORD lpdwSysError);
HB_FUNC( CEFVERSION )
{
hb_retnl( CEFGetVersion( (LPSTR)hb_parc(1) , &dwSysError ) );
}


// DWORD CEFRead(unsigned char *lpMemArea, LPDWORD pdwByteRead, LPDWORD lpdwSysError);
HB_FUNC( CEFREAD )
{
DWORD dwByteRead;

hb_retnl( CEFRead( (LPBYTE)hb_parnl(1) , &dwByteRead , &dwSysError ) );
}

// DWORD CEFWrite(unsigned char *lpCommand, LPDWORD lpdwSysError);
HB_FUNC( CEFWRITE )
{
hb_retnl( CEFWrite( (LPBYTE)hb_parc(1) , &dwSysError ) );
}


// DWORD CEFClose(LPDWORD lpdwSysError);
HB_FUNC( CEFCLOSE )
{
hb_retnl( CEFClose( &dwSysError ) );
}


// DWORD CEFOpen(int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError);
HB_FUNC( CEFOPEN )
{
hb_retnl( CEFOpen( hb_parnl(1) , hb_parnl(2) , hb_parnl(3) , hb_parnl(4) , hb_parnl(5), hb_parnl(6) , &dwSysError ) );
}


// DWORD CEFOpenEth(LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError);
HB_FUNC( CEFOPENETH )
{
LPSTR strIp = (LPSTR) hb_parc(1);

hb_retnl( CEFOpenEth( strIp , hb_parnl(2) , &dwSysError ) );
}


// DWORD CEFOpenUSB(LPTSTR strPrinterName, LPDWORD lpdwSysError);
HB_FUNC( CEFOPENUSB )
{
LPSTR strPrinterName = (LPSTR) hb_parc(1);

hb_retnl( CEFOpenUSB( strPrinterName , &dwSysError ) );
}


// DWORD CEFOpenUnSafe(int intCom, DWORD dwBaudRate, BYTE byParity, BYTE byDataBit, BYTE byStopBit, BYTE byFlowControl, LPDWORD lpdwSysError);
HB_FUNC( CEFOPENUNSAFE )
{
hb_retnl( CEFOpenUnSafe( hb_parnl(1) , hb_parnl(2) , hb_parnl(3) , hb_parnl(4) , hb_parnl(5), hb_parnl(6) , &dwSysError ) );
}


// DWORD CEFOpenEthUnSafe(LPTSTR strIp, DWORD dwPort, LPDWORD lpdwSysError);
HB_FUNC( CEFOPENETHUNSAFE )
{
LPSTR strIp = (LPSTR) hb_parc(1);

hb_retnl( CEFOpenEthUnSafe( strIp , hb_parnl(2) , &dwSysError ) );
}



// DWORD CEFOpenUSBUnSafe(LPTSTR strPrinterName, LPDWORD lpdwSysError);
HB_FUNC( CEFOPENUSBUNSAFE )
{
LPSTR strPrinterName = (LPSTR) hb_parc(1);

hb_retnl( CEFOpenUSBUnSafe( strPrinterName , &dwSysError ) );
}


#pragma ENDDUMP