Important: Please read the Qt Code of Conduct -

OCX or .h +.lib + .dll?

  • Hi guys, I need to stablish a communication with a Fiscal Printer. For that i have the following files downloaded from the official website of the printer:


    To my surprise the header file included throws some extrange error when trying to compile: the sentence FAR PASCAL is not recognised. So i looked what was this and as I read is an old convention to especify parameters and size of pointers. (Precise and concise information here:

    My question is: do i need to delete that part of the code? how can i make this work on QT? If i delete FAR_PASCAL from all the methods i get the error that no library was found so..

    The drivers also include a way to communicate via OCX but as shown in the examples of the drivers documentation is recommended to use them when programming with Visual Basic. Should i change and work with OCX? how can i integrate OCX with QT?

    here is the code of the header:

    #ifndef _WINFIS_H
    #define _WINFIS_H

    #ifdef __cplusplus
    extern "C" {
    #define VERSION 427
    #ifdef WIN32
    #define _export
    typedef void (*PFV)(int Reason, int Port);
    typedef void (__stdcall *PFVSTDCALL)(int Reason, int Port);
    int FAR PASCAL _export OpenComFiscal (int Com, int Mode);
    int FAR PASCAL _export OpenTcpFiscal (char *HostName, int Socket, long TimeoutMilisecs, int Mode);
    #ifdef WIN32
    int FAR PASCAL _export ReOpenComFiscal (int Com);
    void FAR PASCAL _export CloseComFiscal (int Handler);
    int FAR PASCAL _export MandaPaqueteFiscal (int Handler, char *Buffer);
    int FAR PASCAL _export UltimaRespuesta (int Handler, char *Buffer);
    int FAR PASCAL _export UltimoStatus (int Handler, short *FiscalStatus,
    short *PrinterStatus);
    int FAR PASCAL _export VersionDLLFiscal (void);
    int FAR PASCAL _export InitFiscal (int Handler);
    void FAR PASCAL _export BusyWaitingMode (int Mode);
    int FAR PASCAL _export CambiarVelocidad(int Handler, long NewSpeed);
    void FAR PASCAL _export ProtocolMode(int Mode);
    long FAR PASCAL _export SearchPrn (int Handler);
    int FAR PASCAL _export ObtenerNumeroDePaquetes (int Handler,
    int *Enviado, int *Recibido,
    int *CmdRecibido);
    #ifdef WIN32
    void FAR PASCAL _export SetKeepAliveHandler(PFV Handler);
    void FAR PASCAL _export SetKeepAliveHandlerStdCall(PFVSTDCALL Handler);
    void FAR PASCAL _export Abort(int Handler);
    int FAR PASCAL _export SetCmdRetries (int Retries);
    int FAR PASCAL _export SetSndRetries (int Retries);
    int FAR PASCAL _export SetRcvRetries (int Retries);
    int FAR PASCAL _export SetModoEpson (int Modo);
    #define SIZEANSWER 1024
    #define MODE_ASCII 0
    #define MODE_ANSI 1
    #define BUSYWAITING_OFF 0
    #define BUSYWAITING_ON 1
    #define OLD_PROTOCOL 0
    #define NEW_PROTOCOL 1
    #ifdef __cplusplus
    #endif // _WINFIS_H@

    thank you all in advance

  • [Moved this to the C++ gurus forum, it's a pure C/C++ issue and completely unrelated to Qt libs.]

    FAR PASCAL, as explained in the link you posted, are some leftovers from 16 bit days. Nowadays these are defined as macros that expand to nothing, so you might give this a try:

    #define FAR
    #define PASCAL
    #include <winfis.h>

    But be warned, depending on the actual build of that DLLs that could fail miserably and lead to a crash of your application. You will have to try.

  • I tried your approach but i get the following error when i try to do this

    @ int x = OpenComFiscal (1, 1);
    qDebug () << x;

    the function is recognised by the editor and I have the DLL inside the folder that contains my app .exe

    I also included the path to the source (the header) and added to the LIBS variable of my .pro file the library. It`s like the DLL is not functioning


    @#include "windows.h"@

    and compiles. The thing is that im concerned about what you said. Whats are the risks of using this lib? how can I be sure it wont brake?

  • Banned

    This post is deleted!

Log in to reply