[fpc-devel]strange work with dll (dynamic dll)

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Tue Oct 17 21:34:28 CEST 2000


On Tue, 17 Oct 2000, Michail A.Baikov wrote:

> main program:
> 
> Program TestDLLBug;
> 
> Uses    Strings,
>         Windows;
> 
> type
> 
>         xreadconfig = function (var s:string;var s1:string):boolean;
> 
> 
> var
>         pc              :       Pchar;
>         ReadConfig      :       XReadConfig;
>         Handle          :       THandle;
>         S, S1           :       String;
> 
> begin
>   pc:=StrAlloc (length('C:\CORE2.DLL')+1);
>   pc:=StrPCopy(pc,'C:\CORE2.DLL');
> 
>   Handle:=LoadLibrary(pc);
> 
>   Writeln(Handle);
> 
>   if Handle >= 32 then
>   begin
>    @readconfig:=GetProcAddress(Handle,'READCONFIG');
>    if @readconfig=nil then
>    begin
>     Writeln('CORE2.DLL missed or corrupt! Program halt.');
>     halt(252)
>    end;
>   end;
> 
>  writeln('Begin readconfig');
>  readconfig(S,S1);
>  writeln('End readconfig');
>  FreeLibrary(Handle);
> end.
> 
> CORE2.DLL:
> 
> library core2;
> 
> uses windows;
> 
> 
> function readconfig (var S:String;var S1:String):boolean;export;stdcall;
> begin
> assign(output,'');
> writeln('Hello!');
> close(output);
> end;
> 
> exports
>         readconfig;
> 
> begin
> end.
> 
> 
> And this not work.
> 
> 1. Why not work assign(output,'');writeln('blabla');close(output); ? In
> BP70/DPMI all working

AFAIK you cannot write from a dll to standard output. 
I will test this with Delphi tomorrow.

> 2. Why in -S2 option fpc don't allow assign values to an address
> (@readconfig := blablabla (see up)).

Because -S2 is not 'TP' or 'Delphi' syntax; it is ObjFPC syntax.
(And a statement where you assign to an address is strange IMHO)

Michael.





More information about the fpc-devel mailing list