, TInterfacedObject.
, , -1 *).
TComponent, :
TComponent = class(TPersistent, IInterface, IInterfaceComponentReference)
TComponent :
function TComponent._AddRef: Integer;
begin
if FVCLComObject = nil then Result := -1
// -1 indicates no reference counting is taking place
else Result := IVCLComObject(FVCLComObject)._AddRef;
end;
function TComponent._Release: Integer;
begin
if FVCLComObject = nil then Result := -1
// -1 indicates no reference counting is taking place
else Result := IVCLComObject(FVCLComObject)._Release;
end;
*) , VCLComObject , ( -1).
VCLComObject nil.
, IDE, COM-.
: TComponent.ComObject
, . , , .
, :
DoesNotRefCount:= Supports(MyObject, IInterfaceComponentReference)
and (TComponent(MyObject).VCLComObject = nil);
_AddRef , , -1, , ref.
ref 0, _AddRef, _Release, , Delphi _AddRef .
, , :
INoRefCounting = interface
['{CAD60ADF-C49A-46FB-BB5A-CC54BD22C7EB}']
end;
Delphi TSingletonImplementation, no-ref .
Delphi TObject ( TWhatever) no-ref :
function TMyObject.QueryInterface(const IID: TGUID; out Obj): HResult; {stdcall;}
begin
if GetInterface(IID, Obj) then Result := S_OK
else Result := E_NOINTERFACE;
end;
function TMyObject._AddRef: Integer; {stdcall;}
begin
Result := -1;
end;
function TMyObject._Release: Integer; {stdcall;}
begin
Result := -1;
end;
100% , , _AddRef/_Release, VCLComObject.
, , .
, , _AddRef, _Release Destroy, , .