You cannot call this DLL from C #. The main problem is two of object
callbacks. In C # there is no way to match this. You will need to modify the existing DLL or add an intermediate DLL adapter. At its core, your DLL is only available from Delphi or C ++ Builder.
If you can change the DLL, then you will need to change it to remove of object
. If you need a callback to work with an instance, you need to pass the instance as a parameter. However, C # delegates can wrap all this in a transparent way, so you will only need to pass the instance as a parameter if you need a DLL for access from other languages, for example. Delphi
Another problem is the open array parameter. It is also not easy to get from other languages. Although there are tricks , I would recommend passing the reference to the first element, not the open array. Open arrays are unique to Delphi.
I also don't understand why you are using the byte
type to store the length of an array. You must use Integer
for this. There is nothing to gain from using a byte, and you just invite overflow. In addition, MainWindowHandle
should not be THandle
in Delphi. It must be HWND
.
My recommendation would be to modify the DLL to have a C-compatible interface and therefore be accessible from all languages ββthat support this. In practice, this will make it accessible from all major programming languages.
David heffernan
source share