convert C to fivewin

Post Reply
User avatar
vensanto
Posts: 54
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA
Contact:

convert C to fivewin

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: convert C to fivewin

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

Antonio Linares
www.fivetechsoft.com
User avatar
vensanto
Posts: 54
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA
Contact:

Re: convert C to fivewin

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: convert C to fivewin

Post by Antonio Linares »

Are you linking cefdll.lib ?

You have to link it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
vensanto
Posts: 54
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA
Contact:

Re: convert C to fivewin

Post 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
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: convert C to fivewin

Post by cnavarro »

You do not have any file with extension .H ( for #include " .H" )
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
vensanto
Posts: 54
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA
Contact:

Re: convert C to fivewin

Post 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
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: convert C to fivewin

Post 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
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
vensanto
Posts: 54
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA
Contact:

Re: convert C to fivewin

Post by vensanto »

hello i try but i get error

any sample please

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

Re: convert C to fivewin

Post 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
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: convert C to fivewin

Post by cnavarro »

Great
C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: convert C to fivewin

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

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

Re: convert C to fivewin

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

Antonio Linares
www.fivetechsoft.com
User avatar
vensanto
Posts: 54
Joined: Thu Oct 13, 2005 1:26 pm
Location: ITALIA
Contact:

Re: convert C to fivewin

Post by vensanto »

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

Re: convert C to fivewin

Post 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
Post Reply