unit uMainFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask;
type
TMainForm = class(TForm)
btnPkgForm: TButton;
medtOp1: TMaskEdit;
medtOp2: TMaskEdit;
btnAdd: TButton;
lblResult: TLabel;
procedure btnPkgFormClick(Sender: TObject);
procedure btnAddClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
//Defined the method signatures
TAddEmProc = function(Op1, Op2 : Integer) : Integer; stdcall;
TFunkFormProc = procedure; stdcall;
var
MainForm: TMainForm;
const
cFunkForm = 'FunkForm';
cAddEm = 'AddEm';
implementation
{$R *.dfm}
procedure TMainForm.btnAddClick(Sender: TObject);
var
PackageModule : THandle;
AddEmProc : TAddEmProc;
Rslt : Integer;
Op1, Op2 : Integer;
begin
PackageModule := LoadPackage('DdgRTFunk1.bpl');
try
@AddEmProc := GetProcAddress(PackageModule, PChar(cAddEm));
if not (@AddEmProc = nil) then
begin
Op1 := StrToInt(medtOp1.Text);
Op2 := StrToInt(medtOp2.Text);
Rslt := AddEmProc(Op1, Op2);
lblResult.Caption := IntToStr(Rslt);
end;
finally
UnloadPackage(PackageModule);
end;
end;
procedure TMainForm.btnPkgFormClick(Sender: TObject);
var
PackageModule : THandle;
FunkFormProc : TFunkFormProc;
begin
PackageModule := LoadPackage('DdgRTFunk1.bpl');
try
@FunkFormProc := GetProcAddress(PackageModule, PChar(cFunkForm));
if not (@FunkFormProc = nil) then
begin
FunkFormProc;
end;
finally
UnloadPackage(PackageModule);
end;
end;
end.