Recent

Author Topic: Accesing DLL Functions from other languages  (Read 1219 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

  • Hero Member
  • *****
  • Posts: 596
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: 366
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.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

 

TinyPortal © 2005-2018