On Sat, 15 Sep 2007, Sebastian Kraft wrote:

> Hi,
> 
> Isn't it possible to use some functions from a dynamic library and afterwards 
> unload the library?
> can anybody tell me whats wrong with the following code?
> 
> This is my library:
> 
> ++++++++++++++++++++++
> library testlib1;
> 
> function GetString: string;export;
> begin
>   result:='test';
> end;
> 
> exports  GetString;
> end.
> +++++++++++++++++++++++
> 
> and here how it is called
> 
> +++++++++++++++++++++++++
> var
>     libhandle: TLibHandle;
>     GetStringAddr: function: string;
>     str: string;  
> begin
>   libhandle:=LoadLibrary('libtestlib1');
>   pointer(GetStringAddr):=GetProcAddress(FLibraryHandle, 'GetString');
>   str:=GetStrAddr();
>   writeln(str)
>   unloadLibrary(libhandle);
>   writeln(str)
> end.
> +++++++++++++++++++++++
> 
> It always crashes when I want to write 'str' the second time :( 

Probably because the library has closed standard output ?

Michael.

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to