unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    btnClose: TBitBtn;
    btnStart: TBitBtn;
    procedure btnCloseClick(Sender: TObject);
    procedure btnStartClick(Sender: TObject);
  private

  public

  end;

var
  Form1: TForm1;

implementation
{$R *.dfm}
{------------------------------------------------------------------------------}
procedure TForm1.btnCloseClick(Sender: TObject);
begin
	Close();
end;

procedure TForm1.btnStartClick(Sender: TObject);
var
   DLL     : THandle;    // uchwyt biblioteki
   WskForm : procedure;  // uchwyt do procedury

begin
   DLL := LoadLibrary('Forma.dll'); // załaduj bibliotekę
   try
      @WskForm := GetProcAddress(DLL, 'ShowForm');
      if @WskForm = Nil then
      begin
      	raise Exception.Create('Nie mogę znaleć procedury w bibliotece Forma.dll!');
      end
      else begin
      	WskForm();
      end;
   finally
      FreeLibrary(DLL);
   end;
end;

end.

