Which mean I want to call function in delphi VCL/ DLL to retrieve information. Is this possible?
1 Answer
Yes, if the dll is not .Net you will need to use Platform Invoke [DllImport] calls.
Have a look here for windows API examples here (http://pinvoke.net/) which should help you call your delphi dlls.
8 Comments
Lars Truijens
And it also depends on the types you are exporting. Make sure they are not Delphi specific types (no string, no TStringList, etc).
Lars Truijens
Instead of PInvoke you could also make a COM/ActiveX library in Delphi which then can be called from C# using interop.
David Heffernan
@Lars This comment is worthy of being an answer
Mark Redman
@David: As fas as I know creating COM/ActiveX libraries requires registration of the library, which may cause additional issues depending on the situation. Sometimes its just easier to access the existing dll driectly without the additional layer.
David Heffernan
@Mark I'm not advocating one over the other. I'm just saying that both are worthy of consideration. The corresponding downside of P/invoke is that it can be quite hard to get right.
|