type
Ttest = procedure;
procedure TForm1.Button1Click(Sender: TObject);
var
HPackage: THandle;
test: Ttest;
begin
HPackage := LoadPackage('pkgtest.bpl');
if (HPackage <> 0) then
try
@test := GetProcAddress(HPackage, 'test');
if (@test <> nil) then
test
else
RaiseLastWin32Error;
finally
UnLoadPackage(HPackage);
end
else
RaiseLastWin32Error;
end;