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

Michail A.Baikov baikov at mosfilm.ru
Tue Oct 17 20:02:27 CEST 2000


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






More information about the fpc-devel mailing list