I have a problem with dll that contains procedure with Firebird TIBScript.
uses
System.SysUtils,
System.Classes,
DLLMainData in 'DLLMainData.pas' {DataModule2: TDataModule};
{$R *.res}
Procedure RunScript();stdcall;
begin
TDataModule2.RunScriptProc;
end;
exports
RunScript;
begin
end.
dll procedure
class function TDataModule2.RunScriptProc: boolean;
begin
with self.Create(nil) do
begin
try
IBDatabase1.Open;
IBScript1.ExecuteScript;
finally
IBDatabase1.Close;
Free;
end;
end;
end;
Now I call this procedure from an exe as follows:
procedure TForm2.Button1Click(Sender: TObject);
var
Handle: Integer;
LibraryProc :procedure();stdcall;
begin
Handle := LoadLibrary('dllka.dll');
if Handle <> 0 then
begin
try
LibraryProc := GetProcAddress(Handle,'RunScript');
if @LibraryProc = nil then
raise Exception.Create('erorr')
else
LibraryProc();
finally
Showmessage('Before free library');
FreeLibrary(Handle);
Handle := 0;
LibraryProc := nil
end
end;
Showmessage('ok');
end;
When TIBScript raise exception while executing (problem with sql etc.) in main App (witch this procedrue is calling from) hangs on FreeLibrary(). When Script was executed without problems everything works fine. I create small example because i thought that problem was with passing params to library but it is not.
Appreciate any assistance. I am using Delphi XE2. Thanks