[fpc-devel]Error Delphi load DLL, when DLL created in FPC
Zbigniew KuczbaĆski
zbyszek at router.pixel.pl
Wed Nov 20 16:34:55 CET 2002
Hi,
I have problem when I create DLL in FPC. (FPC 1.06 Win32)
1.When create DLL in FPC and use it in program written in FPC - it works
OK.
2. The same DLL (created in FPC) and use in Delphi (6.0) - Delphi report
error when loading DLL.
Error occurs in function LoadLibrary.
When in Delphi I add keyword {$APPTYPE CONSOLE} , Delphi loads my_dll
correctly.
Of course, I need window application.
What I can do, to write DLL in FPC and use it in Delphi.
It's very strange for me, because both use teh same function to Load DLL ->
LoadLibrary!
Best regards
Zb. Kuczbanski
Here sample code my_dll.
----------------------------------------------
Library my_dll;
Begin
WriteLn('Loaded DLL1');
End.
----------------------------------------------
And application written in Delphi.
----------------------------------------------
program test_dll;
uses Windows;
const FarPROC : TFARPROC = nil;
hLib : THandle = 0;
const DLLName = 'my_dll.dll';
Function MyLoadDLL:Word;
var Code : word;
w : longword;
Begin
Code := 0;
try
hLib := LoadLibrary( DLLNAME );
if (hLib < 32) then
Begin
FarProc := NIL;
w := GetLastError;
writeln( 'Error loading librrary ', DLLName, ' error nr = ', w);
Code := $FFFF;
Exit;
end;
finally
MyLoadDLL := Code;
end;
end;
begin
if MyLoadDLL = 0 then
begin
writeln('Load ok.');
end else writeln('Load error');
Writeln('Press ENTER');
Readln;
end.
----------------------------------------------
More information about the fpc-devel
mailing list