First off... I didn't get any problems with SMF on my site yet, but thats a bit off-topic.Originally Posted by Darkhog
Solution for EDIT #1: Comment the exports out while placing components on the form. This is the reason why I suggest making a dynamic library.
Solution for EDIT #2: I did it and it worked for me... Nothing wrong with that.
Solution for EDIT #3: Did you add dynlibs to the uses clause?
[pascal]
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, dynlibs;
[/pascal]
TLibHandle is in dynlibs, so you'll need to add it.
Here is my full source...
[pascal]
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, dynlibs;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
adress: TLibHandle;
implementation
procedure Method1;
begin
ShowMessage('Hello world 1');
end;
procedure Method2;
begin
ShowMessage('Hello World 2');
end;
type
TMyMethod = procedure; stdcall;
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
mp: TMyMethod;
begin
mp := TMyMethod(GetProcAddress(adress, 'Method1'));
mp;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
mp: TMyMethod;
begin
mp := TMyMethod(GetProcAddress(adress, 'Method2'));
mp;
end;
exports Method1 name 'Method1';
exports Method2 name 'Method2';
initialization
{$I Unit1.lrs}
end.
[/pascal]
Bookmarks