Create a C# DLL That Can Be Imported in a Delphi App Using stdcall - Possible?

后端 未结 9 1554
孤城傲影
孤城傲影 2020-12-09 19:35

I have a program that I need to create a DLL for, hopefully in C#. The program is written in Delphi and I have an interface file to code to. The interface uses the stdcall

相关标签:
9条回答
  • 2020-12-09 20:25

    I'm assuming here that the Delphi app is not a .NET based app and therefore you need to host the .NET runtime in a Win32 process.

    • Hosting the .NET runtime in a Delphi Program
    • .Net interop - using C# assembly from Delphi Win32
    • CorBindToRuntimeEx

    CorBindToRuntimeEx is a function inside MSCorEE.dll, which holds the .NET runtime. With it you can host the runtime and then create objects inside it and interact with them.

    0 讨论(0)
  • 2020-12-09 20:29

    This is not directly possible. C# is managed code. This means that it requires a very specific runtime environment in order to function, an environment which Delphi could not directly provide to it. It is not like C where you simply find the address and calling convention of the function and call it.

    However, it is possible to host the Common Language Runtime inside of a Delphi application (or any other Windows application). I have no idea how to do this. I just know that it's possible. (It's quite likely that's what this 'Hydra' that Steve mentioned will do.)

    0 讨论(0)
  • 2020-12-09 20:38

    Have a look at Hydra

    0 讨论(0)
提交回复
热议问题