0

The delphi dll code like this:

function TCP_CHECKOUT(const RoomName:string; ClearCard:boolean):Byte

when I call it in c#,but always get the error return code. My c# code like this:

[DllImport(@"EHLKEY.dll", EntryPoint = "TCP_CHECKOUT")]
public extern static Byte TCP_CHECKOUT(string RoomName, bool ClearCard);

The delphi code user said the return code 255 is not call success.Somebody can help me to solve it?Thanks!

7
  • The Delphi code is wrong. Delphi's string is not appropriate for interop, and neither is boolean. Contact the author of the DLL and tell them to use appropriate types for the parameters.
    – Ken White
    Commented Feb 25, 2017 at 3:49
  • Delphi's calling convention is not MS fastcall. This function can't be called from c#. You'll need to change the Delphi code to allow that. Commented Feb 25, 2017 at 5:07
  • @KenWhite Any other method to avoid this misstake?Can I use c++ or others to call it,then use the middleware in c#.
    – J.Yang
    Commented Feb 25, 2017 at 5:27
  • @DavidHeffernan You are right.Any other method to solve this problem?
    – J.Yang
    Commented Feb 25, 2017 at 5:29
  • If you can't change the Delphi code then you may need a delphi wrapper in the middle to act as an adapter. But even that might fail if the memory management is handled wrongly by the DLL. Not enough information here to be sure. Commented Feb 25, 2017 at 5:31

0

Browse other questions tagged or ask your own question.