Bematech MP-4200 TH expects Imprint

3

Good afternoon I'm developing an application that needs to be sure that the document was printed on the bematech thermal printer MP-4200 TH, as the printer has buffer even if it has no paper in it, it sends the command to the printer and returns as ok , so I can not know if it was actually printed or just sent to printer, verifying the class has a function that according to the documentation makes the application wait for the end of the printout.

/// <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 by returning it unbalanced the stack.

    
asked by anonymous 18.02.2016 / 19:55

1 answer

0

This type of error is usually tied to a thing known as Calling Convention and the attribute [DllImport] has a property in which you define which mode should be used for the imported function.

When you do not specify any, C # sets the StdCall and it should not be how the dll you use has been compiled, see the link above the other values you can use, the most used types are StdCall and Cdecl.

It would look something like this:

[DllImport("MP2032.dll", CallingConvention=CallingConvention.Cdecl)]
public static extern int EsperaImpressao(int modo);
    
18.02.2016 / 22:11