convert C to fivewin

convert C to fivewin

Postby vensanto » Mon May 22, 2017 4:21 pm

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
User avatar
vensanto
 
Posts: 58
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA

Re: convert C to fivewin

Postby Antonio Linares » Mon May 22, 2017 5:03 pm

// 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 ) );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: convert C to fivewin

Postby vensanto » Tue May 23, 2017 5:45 am

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
User avatar
vensanto
 
Posts: 58
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA

Re: convert C to fivewin

Postby Antonio Linares » Tue May 23, 2017 8:21 am

Are you linking cefdll.lib ?

You have to link it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: convert C to fivewin

Postby vensanto » Tue May 23, 2017 3:29 pm

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
User avatar
vensanto
 
Posts: 58
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA

Re: convert C to fivewin

Postby cnavarro » Tue May 23, 2017 3:38 pm

You do not have any file with extension .H ( for #include " .H" )
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: convert C to fivewin

Postby vensanto » Tue May 23, 2017 5:18 pm

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
User avatar
vensanto
 
Posts: 58
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA

Re: convert C to fivewin

Postby cnavarro » Tue May 23, 2017 5:22 pm

Ok, try putting these lines at the beginning of the .C file, after the includes

Code: Select all  Expand view  RUN

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
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: convert C to fivewin

Postby vensanto » Wed May 24, 2017 1:42 pm

hello i try but i get error

any sample please

thanks
User avatar
vensanto
 
Posts: 58
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA

Re: convert C to fivewin

Postby vensanto » Wed May 24, 2017 6:11 pm

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
User avatar
vensanto
 
Posts: 58
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA

Re: convert C to fivewin

Postby cnavarro » Wed May 24, 2017 6:13 pm

Great
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: convert C to fivewin

Postby Antonio Linares » Thu May 25, 2017 7:29 am

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 ) );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: convert C to fivewin

Postby Antonio Linares » Thu May 25, 2017 7:32 am

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  Expand view  RUN
HB_FUNC( CEF_GETSYSERROR )
{
   hb_retnl( dwSysError );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: convert C to fivewin

Postby vensanto » Thu May 25, 2017 1:03 pm

Thank You Antonio
User avatar
vensanto
 
Posts: 58
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA

Re: convert C to fivewin

Postby vensanto » Thu May 25, 2017 1:12 pm

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
User avatar
vensanto
 
Posts: 58
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 105 guests