2
I need help loading the DLL BemaFI32.dll
dynamically in the Delphi.
My code is 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 return of the function is always -4, indicating that the file does not exist BemaFI32.ini
. But the file exists.
I’ve tried to perform the functions Bematech_FI_ReloadINIFile
and Bematech_FI_AbrePortaSerial
before, but always returns the same error.
I am developing in Delphi XE2, in Windows 10 64 bits. However I have also tested with Windows 7 and the same problem occurs.
The version of Bemafi32.dll is 7.0.4.32.
Has anyone ever had a similar problem?
The archive
BemaFI32.ini
has to be in the Windows system directory. Are you sure that it is there?– stderr
@zekk, thanks for the help. A dll and ini are in the same executable folder. I did a test now with those file in Windows folder and it also didn’t work. If I use the dll statically, the function runs smoothly.
– Ronaldo Brisola
Maybe it could be a problem with the
UAC
, have you tried running the application as an administrator? read on: https://msdn.microsoft.com/pt-br/library/windows/desktop/aa384187(v=vs.85). aspx– stderr
@zekk, Following your initial tip, I put the files in the Syswow64 folder. Ai worked perfectly! I really appreciate your help.
– Ronaldo Brisola
Ronaldo, if you want to post this as an answer, it would help others!
– stderr