Author
Topic: Importing function from dll (Read 1484 times)

Hello guys.I came from Delphi and am starting to use this wonderful tool called Lazarus, but I'm having some problems importing functions from a dll.I do exactly as in Delphi but the compiler accuses error in LazarusHere is the code:

But using string as the result of a function is a bad idea. A string is a managed type, and you will have both a program and a library to manage it. There may be conflicts (no memory release or double release).

Indeed. Although in principle and only fpc.dll to fpc execuatable (or delphi dll and delphi executable) can work both ways with strings if a shared memory manager is installed.(e.g. sharemem.dll for Delphi)But generally do not use Pascal strings, with shared libraries use PChar string types. That will also work with other languages.

The exception is COM dll's and their type libraries, together with the use of BWSTR/WideString types: these will work since those are not reference counted by FPC but by a COM marshaller but that depends on platform (usually windows only)