Recent

Author Topic: Accesing DLL Functions from other languages  (Read 439 times)

PsaCrypt

  • New member
  • *
  • Posts: 21
Accesing DLL Functions from other languages
« on: December 11, 2018, 06:03:28 am »
Hello,

I want to know how to call a DLL external function compiled with different languages than FPC, and storing returned values from called functions into FPC memory variables.  Could I do this?  If yes, Could I do this for getting array returned from called function too?

Thank you.  :-)

CCRDude

  • Sr. Member
  • ****
  • Posts: 491
Re: Accesing DLL Functions from other languages
« Reply #1 on: December 11, 2018, 09:32:48 am »
Yes, you can.

Either using LoadLibrary and GetProcedureAddress, or by specifying the function and adding external libname. See the Lazarus Wiki.

And sure, "arrays" can be exchanged. There's a huge range of options to do so, you'll have to understand and implement the way the DLL passes them.

sash

  • Sr. Member
  • ****
  • Posts: 252
Re: Accesing DLL Functions from other languages
« Reply #2 on: December 11, 2018, 10:32:30 am »
Could I do this for getting array returned from called function too?

Generally yes, but take in account that everything except base (and compatible) types should be passed by pointer.
Lazarus 2.0.2 FPC 3.0.4 x86_64-linux-gtk2 -- Ubuntu 19.04 XFCE