Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Communication driver QPrintFM.dll Version 2.x.x.

x
How to implement the QPrintFM.dll in your project
First of all to use the QPrintFm.dll for your application it is required that your application knows where is
the QPrintFM.dll is stored. The best solution is to Copy the QPrintFM.dll to the folder of your application
binary file.

Borland C++:
Add the QPrintFM.lib to your project (required to call the available function)

To use the function in your source you should append the following line to your *.c file:

extern "C" __declspec(dllimport) char* __stdcall TransmitPrinterCommand(int IPCom, char*


Port, int BaudRateNr, char* Command);

Now you can call the QPrintFM.dll function in your *.c file like this:

TransmitPrinterCommand(..., ..., ..., ...);

Visual Basic:
To use the function you should implement the following lines to your *.frm file:

Dim ModLibReturn As Long

Private Declare Function FreeLibrary Lib "kernel32.dll" (ByVal hLibModule As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32.dll" Alias "LoadLibraryA" (ByVal
lpLibFileName As String) As Long

Private Declare Function TransmitPrinterCommand Lib "QPrintFM.dll" (ByVal IPCom As Integer,


ByVal Port As String, ByVal BaudRateNr As Long, ByVal Command As String) As String

Now should implement the LoadLibary function in the form load event like this:

Private Sub Form_Load()


ModLibReturn = LoadLibrary(App.Path & "\QPrintFM.dll")
If ModLibReturn = 0 Then MsgBox "QPrintFM.dll not found", vbCritical
End Sub

If you load the libary you shouldnt forget to give it free. In this case you should call the
FreeLibrary function on your form termination like this:

Private Sub Form_Terminate()


If ModLibReturn <> 0 Then Call FreeLibrary(ModLibReturn)
End Sub

Now you can call the QPrintFM.dll in your *.frm file like this:
TransmitPrinterCommand(..., ..., ..., ...)
Transmit Command
Function:
char* TransmitPrinterCommand(int IPCom, char* Port, int BaudRateNr, char* Command);

Parameters:
int IPCom = the connection mode (0 = Serial COM connection , 1 = Ethernet connection)
char* Port = is the interface that you would reach
for COM-> (COM1,
COM2,
COM3,
COM4,
COM5,
COM6,
COM7,
COM8, ...)
for Ethernet-> (192.168.1.200,
192.168.1.201, ...)
[is the printer base IP address]
int BaudRateNr = is the transmission rate or the printer number (by Ethernet)
for COM-> (1200,
2400,
4800,
9600,
19200,
38400,
57600,
115200)
for Ethernet-> printer number if you use more then one printer into a network

char * Command = Command string that should be execute by the printer

Return Value as hex string:


0x11 = cant open COM-Port
0x21 = no valid IP address
0x22 = error opening IP
0x23 = invalid Socket
0x31 = timeout
0x32 = connection timeout
String that replace more than one hex value = Answer from fiscal printer (see Communication
Protocol Manual)

You might also like