I've recently compiled a DLL using the 64-bit MSYS2 MinGW and it compiled successfully. I can browse it using DLL Explorer.
But, I can't load it with LoadLibrary using Lazarus 2.0.12 and FPC 3.2.0 on 64-bit Windows 10.
I have created a small demo project and supplied the DLL in the hope someone might look at it and see if the problem is my code, or the DLL itself.
I have Googled the various reasons that LoadLibrary fails, and all the answers seem to relate to things like permissions or filenames. It keeps returning 0 with me, but I can't see WHY its returning zero, because the name string of the filename shows correctly in the debugger and the permissions are allowed to execute it and the path is valid. I've tried using Unicode string, rawbytestring, and normal string. I've tried using THandle and TLibHandle. Just can't get anything other than 0.
It would be a big help if someone could try it for me and see if they can get a non-zero value? Or has the DLL being made incorrectly? DLL Explorer shows all the valid functions in it.
procedure TForm1.Button1Click(Sender: TObject);
var
//libFileName : Unicodestring;
// libFileName : RawByteString;
libFileName : string;
fLibHandle : TLibHandle;
// fLibHandle : THandle;
begin
fLibHandle := nilhandle;
//libFileName:=ExtractFilePath(Application.ExeName)+'libewf-v3.dll'; /// gets full path to DLL OK
libFileName:='libewf-v3.dll'; // if DLL in same folder as exe
if FileExists(libFileName) then
begin
fLibHandle := LoadLibrary(PChar(libFileName)); // Keeps returning zero
//fLibHandle := dynlibs.LoadLibrary(libFileName);
//fLibHandle := LoadLibraryA(PAnsiChar(libFileName)); // Windows API method
if fLibHandle<>nilhandle then
begin
Label1.Caption := 'Success';
end
else Label1.Caption := 'Failed';
end;
end;
Sample project with the DLL in question here :
https://we.tl/t-FeC0iquYgX