Felipe
Felipe

Reputation: 266

How can I call a C method from a library on my C# code?

I have a DLL (CliSiTef32I.dll) and I need to call the following methods on my C# code:

//The DLL can be downloaded at http://54.197.252.236/se/CliSiTef32I.dll

long ConfiguraIntSiTefInterativoEx(
   char* IPSiTef, 
   char* IdLoja,
   char* IdTerminal, 
   short Reservado, 
   char* ParametrosAdicionais
   )

long IniciaFuncaoSiTefInterativo(
   long Funcao, 
   char* Valor, 
   char* CupomFiscal, 
   char* DataFiscal, 
   char* HoraFiscal, 
   char* Operador, 
   char* ParamAdic
   )

How can I do this?

Upvotes: 1

Views: 252

Answers (1)

Kris Vandermotten
Kris Vandermotten

Reputation: 10201

These might do the job:

[DllImport("CliSiTef32I.dll")]
public static extern int ConfiguraIntSiTefInterativoEx (
    byte[] IPSiTef, 
    byte[] IdLoja, 
    byte[] IdTerminal, 
    short Reservado, 
    byte[] ParametrosAdicionais)

[DllImport("CliSiTef32I.dll")]
public static extern int IniciaFuncaoSiTefInterativo (
    long Funcao, 
    byte[] Valor, 
    byte[] CupomFiscal, 
    byte[] DataFiscal, 
    byte[] HoraFiscal, 
    byte[] Operador, 
    byte[] ParamAdic)

I'm not entirely sure about the meaning of short though. If that's a 16 bit signed int, this will work.

Also, if the 32 bit int that you are returning is really a bool, you might declare the return value as such.

Upvotes: 2

Related Questions