Win64上的接口委派

时间:2012-01-16 20:08:23

标签: delphi interface delphi-xe2 delegation

Documentation表示接口委派仅适用于Win32。目前我无法测试它,是否在64位编译器中停止了文档错误或接口委托?

1 个答案:

答案 0 :(得分:9)

这是一个文档错误。 Win64下面发出以下哔声:

program Win64delegatedInterfaces;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  IIntf = interface
    procedure Foo;
  end;

  TMyClass = class(TObject, IIntf)
    FIntf: IIntf;
    property Intf: IIntf read FIntf implements IIntf;
  end;

  TMyOtherClass = class(TInterfacedObject, IIntf)
    procedure Foo;
  end;

var
  MyClass: TMyClass;
  Intf: IIntf;

procedure TMyOtherClass.Foo;
begin
  Beep;
end;

begin
  MyClass := TMyClass.Create;
  MyClass.FIntf := TMyOtherClass.Create;
  Intf := MyClass;
  Intf.Foo;
end.