Hi. I'm trying to use interfaces in Delphi, but I want to disable
reference counting. So I created a new class (shown below) with a
method to free the object, but when I call ReleaseObject() I get an
access violation after "Free".
Anyone got any ideas about how I can free the interfaced object when I
only have a reference to the interface?

Todd

  IamUnknown = interface(IUnknown)
  ['{171F7C01-2C89-11D7-815B-2C9E07C10000}']
    procedure ReleaseObject;
  end;

  TamInterfacedObject = class(TObject,IamUnknown)
  protected
    function QueryInterface(const IID: TGUID; out Obj): HResult;
stdcall;
    function _AddRef: Integer; stdcall;
    function _Release: Integer; stdcall;
    procedure ReleaseObject;
  end;

procedure TamInterfacedObject.ReleaseObject;
begin
   Free;
end;

function TamInterfacedObject._AddRef: Integer;
begin
  //do nothing - ignore reference counting
  Result := 0;
end;

function TamInterfacedObject._Release: Integer;
begin
  //do nothing - ignore reference counting
  Result := 0;
end;

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to