unit fmMain;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    afxDemo: TActiveFormX;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses ComObj;

procedure TForm1.Button1Click(Sender: TObject);
var
  anIntf : IActiveFormX;
  aDisp : IDispatch;
  iCount, iAddRef, iReleaseRef : Integer;
  IID_DISPATCH : TGUID;
begin
  IID_DISPATCH := StringToGUID('{00020400-0000-0000-C000-000000000046}');
  anIntf := afxDemo.DefaultInterface;
  anIntf.QueryInterface(IID_DISPATCH, aDisp);
  iAddRef := aDisp._AddRef;
  iReleaseRef := aDisp._Release;
  Self.Edit1.Text := IntToStr(iAddRef);
  Self.Edit2.Text := IntToStr(iReleaseRef);

  aDisp.GetTypeInfoCount(iCount);
  Self.Caption := IntToStr(iCount);
end;

end.
