Is there a non-reference-counted base class like TInterfacedObject?

前端 未结 5 1415
无人及你
无人及你 2021-02-07 08:47

I need a base class like TInterfacedObject but without reference counting (so a kind of TNonRefCountedInterfacedObject).

This actually is the

5条回答
  •  心在旅途
    2021-02-07 09:16

    In the unit Generics.Defaults there is a class TSingletonImplementation defined. Available in Delphi 2009 and above.

      // A non-reference-counted IInterface implementation.
      TSingletonImplementation = class(TObject, IInterface)
      protected
        function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
        function _AddRef: Integer; stdcall;
        function _Release: Integer; stdcall;
      end;
    

提交回复
热议问题