unit Unit2;

interface

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

function ShowAbout(Handle: THandle):LongInt;stdcall;
procedure FreeAbout(FormRef: LongInt);export;stdcall

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    f:LongInt;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  function ShowAbout;external 'ProjectDLL.dll' index 10;
  procedure FreeAbout;external 'ProjectDLL.dll' index 11;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
 if f>0 then
  FreeAbout(f);
 f:=ShowAbout(Handle);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 FreeAbout(f);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
 f:=0;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 if f>0 then
  FreeAbout(f);
end;

end.
