Below is an example for working with fiscal printer Camel and Spark
>From BMC using the dll ftpctrl.dll supplied by the Venezuela sales

office.

I had tried to use the IMPORT command, but does not work for two
reason:
1- The dll cannot be released between all calls
2- The dll return parameters by pointers and maybe my skills are not
correctly in this topic. Maybe some lights from Ron can be helpfull

I hope this code maybe usefull for some xharbour user.
Marcelo Anelli

Function BMC_Reportex()
// ------------------
// Imprimir reporte x
// ------------------
PRIVATE cBuf
PRIVATE nStatus
PRIVATE nError
BFI_RETORNO := OpenFpctrl( cImpPuerto )
cBuf := ""
cBuf := cBuf + "I1Z"
BFI_RETORNO := SendCmd( @nStatus, @nError, cBuf)
BFI_RETORNO := CloseFpctrl()
Return .T.

// ------------------------------------------------------------
// Rutinas requeridas para la impresora Camel BMC Fiscal usando
// fpctrl.dll para Venezuela.
// ------------------------------------------------------------

/*
#include "hbdll.ch"

IMPORT LONG OpenFpctrl( LPCTSTR cBFI_lPortName ) ;
FROM fpctrl.dll

IMPORT LONG CloseFpctrl() FROM fpctrl.dll

IMPORT LONG CheckFprinter() FROM fpctrl.dll

IMPORT LONG ReadFpStatus( LONG nBFI_Status, LONG cBFI_Error ) ;
FROM fpctrl.dll

IMPORT LONG SendCmd( LONG nBFI_Status, LONG cBFI_Error, ;
LPCSTR cBFI_Command ) FROM fpctrl.dll

IMPORT LONG SendNCmd( LONG nBFI_Status, LONG cBFI_Error, ;
LPCSTR cBFI_Buffer ) FROM fpctrl.dll

IMPORT LONG SendFileCmd( LONG nBFI_Status, LONG cBFI_Error, ;
LPCSTR cBFI_File ) FROM fpctrl.dll

IMPORT LONG UploadReportCmd( LONG nBFI_Status, LONG cBFI_Error, ;
LPCSTR cBFI_Cmd, LPCSTR cBFI_File ) FROM fpctrl.dll
*/

//status
#define FPCTL_NON_STATUS 0
#define FPCTL_NON_FISCAL_IN_IDLE 1
#define FPCTL_NON_FISCAL_IN_TRANSACTION 2
#define FPCTL_NON_FISCAL_NON_TRANSACTION 3
#define FPCTL_FISCAL_IN_IDLE 4
#define FPCTL_FISCAL_IN_TRANSACTION 5
#define FPCTL_FISCAL_NON_TRANSACTION 6
#define FPCTL_FISCAL_MEMORY_NEAR_FULL_IN_TRANSACTION 7
#define FPCTL_FISCAL_MEMORY_NEAR_FULL_NON_TRANSACTION 8
#define FPCTL_FISCAL_MEMORY_NEAR_FULL_IN_IDLE 9
#define FPCTL_FISCAL_MEMORY_FULL_IN_TRANSACTION 10
#define FPCTL_FISCAL_MEMORY_FULL_IN_NON_TRANSACTION 11
#define FPCTL_FISCAL_MEMORY_FULL_IN_IDLE 12
#define FPCTL_SENDNCMD_SUCCESS 0

// error
#define FPCTL_ERROR_NO_ERROR 0
#define FPCTL_ERROR_PAPER_END 1
#define FPCTL_ERROR_PRINTER_MECHA_ERROR 2
#define FPCTL_ERROR_PAPER_END_MECHA_ERROR 3
#define FPCTL_ERROR_COMMAND_INVALID_VAL 80
#define FPCTL_ERROR_COMMAND_INVALID_TAX 84
#define FPCTL_ERROR_NOT_ASSIGNED_CLERK 88
#define FPCTL_ERROR_INVALID_COMMAND 92
#define FPCTL_ERROR_FISCAL_ERROR 96
#define FPCTL_ERROR_FISCAL_MEMORY_ERROR 100
#define FPCTL_ERROR_FISCAL_MEMORY_FULL 108

#define FPCTL_ERROR_BUFFER_FULL 112
#define FPCTL_ERROR_ANSWERED_NAK 128
#define FPCTL_ERROR_NOT_ANSWERED 137
#define FPCTL_ERROR_UNKNOWN_ANSWERED 144
#define FPCTL_ERROR_COMM_API 145
#define FPCTL_ERROR_FILE_OPEN 153

FUNCTION ElErrorFpctrl( nError )
LOCAL cMensaje := ""
DO CASE
CASE nError == FPCTL_ERROR_PAPER_END
cMensaje := "Fin de papel"
CASE nError == FPCTL_ERROR_PRINTER_MECHA_ERROR
cMensaje := "Error en el mecanismo"
CASE nError == FPCTL_ERROR_PAPER_END_MECHA_ERROR
cMensaje := "Fin de papel auditoría"
OTHERWISE
IF nError > 0
cMensaje := "Código " + Str( nError )
ENDIF
END
IF Len( cMensaje ) > 0
MsgInfo( "Error impresora fiscal: " + cMensaje )
ENDIF
Return .T.

#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"

HINSTANCE dllhandle;

typedef LONG (WINAPI * _OPENFPCTRL)(LPSTR ComPuerto);
typedef LONG (WINAPI * _CLOSEFPCTRL)(VOID);
typedef LONG (WINAPI * _SENDCMD)(LONG * status, LONG * error, LPSTR
cmd);
typedef LONG (WINAPI * _SENDNCMD)(LONG * status, LONG * error, LPSTR
buffer);
typedef LONG (WINAPI * _SENDFILECMD)(LONG * status, LONG * error,
LPSTR buffer);
typedef LONG (WINAPI * _UPLOADREPORTCMD)(LONG * status, LONG *
error, LPSTR buffer, LPSTR archivo);

HB_FUNC( OPENFPCTRL )
{
LPSTR ComPuerto = hb_parc( 1 );
dllhandle = LoadLibrary("FPCTRL.DLL");
if (dllhandle)
{
_OPENFPCTRL pFunc;
pFunc = (_OPENFPCTRL) GetProcAddress(dllhandle, "OpenFpctrl");
hb_retnl( pFunc( ComPuerto ) );
}
}

HB_FUNC( CLOSEFPCTRL )
{
if (dllhandle)
{
_CLOSEFPCTRL pFunc;
pFunc = (_CLOSEFPCTRL) GetProcAddress(dllhandle, "CloseFpctrl");
hb_retnl( pFunc() );
FreeLibrary( dllhandle );
}
}

HB_FUNC( SENDCMD )
{
if (dllhandle)
{
LONG status;
LONG error;
LPSTR cmd = hb_parc( 3 );
_SENDCMD pFunc;
pFunc = (_SENDCMD) GetProcAddress(dllhandle, "SendCmd");
hb_retnl( pFunc( &status, &error, cmd ) );
hb_stornl( status, 1 );
hb_stornl( error, 2 );
}
}

HB_FUNC( SENDNCMD )
{
if (dllhandle)
{
LONG status;
LONG error;
LPSTR Buffer = hb_parc( 3 );
_SENDNCMD pFunc;
pFunc = (_SENDNCMD) GetProcAddress(dllhandle, "SendNCmd");
hb_retnl( pFunc( &status, &error, Buffer ) );
hb_stornl( status, 1 );
hb_stornl( error, 2 );
}
}

HB_FUNC( SENDFILECMD )
{
if (dllhandle)
{
LONG status;
LONG error;
LPSTR Buffer = hb_parc( 3 );
_SENDFILECMD pFunc;
pFunc = (_SENDFILECMD) GetProcAddress(dllhandle, "SendFileCmd");
hb_retnl( pFunc( &status, &error, Buffer ) );
hb_stornl( status, 1 );
hb_stornl( error, 2 );
}
}

HB_FUNC( UPLOADREPORTCMD )
{
if (dllhandle)
{
LONG status;
LONG error;
LPSTR Buffer = hb_parc( 3 );
LPSTR archivo = hb_parc( 4 );
_UPLOADREPORTCMD pFunc;
pFunc = (_UPLOADREPORTCMD) GetProcAddress(dllhandle,
"UploadReportCmd");
hb_retnl( pFunc( &status, &error, Buffer, archivo ) );
hb_stornl( status, 1 );
hb_stornl( error, 2 );
}
}

#pragma ENDDUMP