[Lazarus] Call Load/Unload library from procedure

Thierry Coq tcoq at free.fr
Wed Feb 3 10:49:32 CET 2010


Hello,

I confirm the calling conventions should match. Maybe try using the 
pascal calling convention to debug your code, it is more robust.

In addition, using strings in DLL calls is a <bad idea> for a beginner. 
Start with arrays of char or PChar.
Allocate the memory to the PCHAR and pass it as a parameter to the DLL. 
Don't forget to provide the length of the string, so there is no buffer 
overrun.

For more complex calls, and if you compile your own DLLs, you might want 
to look here for an example (Dynamic Loading Library):
http://www.tcoq.org/Lazarus.html, it reproduces the dynamic loading 
equivalent in Delphi.

BR
Thierry

cobines wrote:
> 2010/2/3 fabio <bor400 at gmail.com>:
>   
>> Hi,
>> I need help with libraries. I'm working on Win XP with lazarus 0.9.29
>> and fpc 2.4.1.
>> I attached sample project app and project library.
>> I'm not sure whether this is a bug or something I do not know, the
>> problem is that when I use library in public form procedure I get the
>> Access Violation when procedure is ended.
>>
>> I'll be grateful for help.
>>     
>
> You have specified different calling conventions: cdecl in main
> program and stdcall in the library. I think calling conventions should
> match.
>
> --
> cobines
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
>   





More information about the Lazarus mailing list