On 2013-03-21 10:54, Sven Barth wrote:
> If you just want plain interfaces like in Java and other 
> languages than you need to use what is called "CORBA" interfaces in FPC.

Delphi doesn't have CORBA style interfaces like FPC. The work-around in
Delphi was to implement TNullInterfacedObject which has the IUnknown
signature, but no reference counting is done.

eg:
type
  // non reference counted interface
  TNullInterfacedObject = class(TObject, IUnknown)
  protected
    function QueryInterface(const IID: TGUID; out Obj): longint; stdcall;
    function _AddRef: longint; stdcall;
    function _Release: longint; stdcall;
  end;


{ TNullInterfacedObject }

function TNullInterfacedObject.QueryInterface(const IID: TGUID; out
Obj): longint; stdcall;
begin
  if GetInterface(IID, Obj) then
    Result := 0
  else
    result := integer(e_nointerface);
end;

function TNullInterfacedObject._AddRef: longint; stdcall;
begin
  Result := -1;
end;

function TNullInterfacedObject._Release: longint; stdcall;
begin
  Result := -1;
end;


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/


--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to