Hi.
I wrote a library that exposes a procedure called "Crea" that creates and shows a form. The code of library is:
library libreria;
{$mode objfpc}{$H+}
uses Sharemem, Classes, Forms, Interfaces;
procedure Crea;stdcall; begin with TForm.CreateNew(nil) do begin Top:=100; Left:=100; Width:=100; Height:=100; Show; end; end;
exports Crea;
begin end.
|
Then, I wrote a usually application that invokes the procedure "Crea":
unit Unit1;
{$mode objfpc}{$H+}
interface
uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, DynLibs;
type TCrea=procedure;stdcall;
{ TForm1 }
TForm1 = class(TForm) Button2: TButton; procedure Button2Click(Sender: TObject); private { private declarations } public { public declarations } end;
var Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button2Click(Sender:TObject); var HandleLibreria:TLibHandle; Crea:TCrea; begin HandleLibreria:=LoadLibrary('libreria.dll'); if (HandleLibreria<>0) then begin Crea:=TCrea(GetProcedureAddress(HandleLibreria,'Crea')); Crea; end; end;
end.
|
(The project have the unit "Sharemem" as first unit).
Well, when I run the application, the "Crea" procedure is correctly executed. But, when the instruction "Show" in the "Crea" library procedure is executed, I get the external "SIGSEGV" exception.
Can anyone help me?
My operative system is Windows XP.
Thanks in advance.
Sergio.