Bematech MP-4200 TH waitingPrinting

Asked

Viewed 641 times

3

Good afternoon I am developing an application that needs to make sure that the document was printed on the non tax thermal printer Bematech MP-4200 TH, as the printer has buffer even if there is no paper in it it sends the command to the printer and returns as ok, so I have no way of knowing if it was actually printed or if it was just sent to the printer, verifying the class has a function that according to the documentation makes the application wait for the end of the printing.

/// <summary>
/// Esta função segura a execução do Aplicativo, até que todo o texto enviado seja impresso.
/// </summary>
/// <param name="modo">INTEIRO modo de espera.</param>
/// <returns>INTEIRO - Indica se a função conseguiu enviar o comando para impressora.</returns>
[DllImport("MP2032.dll")]
public static extern int EsperaImpressao(int modo);

However this is not working returning that this unbalanced the stack.

1 answer

0


This kind of mistake is usually tied to something known as Calling Convention and the attribution [DllImport] has a property in which you define which mode should be used for the imported function.

When you do not specify any the C# sets by default the Stdcall and should not be like the dll that you utilza was compiled, see in the link above the other values that you can use, the most used types are Stdcall and Cdecl.

It would be something like:

[DllImport("MP2032.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int EsperaImpressao(int modo);
  • Thank you solved the problem!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.