Load Dynamic DLL (BemaFI32) in Delphi

2

I need help on how to load the BemaFI32.dll DLL dynamically in Delphi.

My code looks like this:

function _Bematech_FI_NumeroSerie(NumeroSerie: AnsiString): Integer;
var
  xBematech_FI_NumeroSerie : function ( NumeroSerie: AnsiString ): Integer; stdcall;
  lHandle : THandle;
begin
  lHandle := LoadLibrary('bemafi32.dll');
  @xBematech_FI_NumeroSerie := GetProcAddress(lHandle, PChar('Bematech_FI_NumeroSerie'));

  if @xBematech_FI_NumeroSerie = nil then
    raise Exception.Create('Entrypoint Bematech_FI_NumeroSerie não encontrado na Dll');

  Result := xBematech_FI_NumeroSerie(NumeroSerie);
end;

The function return is always -4 , indicating that the BemaFI32.ini file does not exist. But the file exists.

I have tried to execute the functions Bematech_FI_ReloadINIFile and Bematech_FI_AbrePortaSerial before, but always returns the same error.

I'm developing on Delphi XE2 in Windows 10 64 bit. However, I have also tested Windows 7 and the same problem occurs.

The version of BemaFi32.dll is 7.0.4.32.

Has anyone ever had a similar problem?

    
asked by anonymous 08.08.2016 / 19:31

2 answers

2

Following the @zekk tip, I put the BemaFi32.ini file in the C: \ WINDOWS \ SysWOW64 folder.

That way communication with the DLL worked.

    
09.08.2016 / 16:39
0

I did the same thing I put in the SysWOW64 folder, it seems that only happens with Windows 64bit. puts all dlls in the SysWOW64 folder right.

    
22.09.2017 / 15:59