Board index » delphi » Correct way to free IStream

Correct way to free IStream

Hi there,
i am using an OLE compound file, and i am wondering, what is the correct
way to free my IStream objects.
MS documentation says, i should call the release method, but this method
is protected in Delphi, and i get Exceptions if i call it.
Anyone with more infos?

TIA
Henning

 

Re:Correct way to free IStream


"Henning Kiel" <henning.k...@rwth-aachen.de> schrieb im Newsbeitrag
news:3D64EE4D.8050807@rwth-aachen.de...

Quote
> i am using an OLE compound file, and i am wondering, what is the correct
> way to free my IStream objects.
> MS documentation says, i should call the release method, but this method
> is protected in Delphi, and i get Exceptions if i call it.
> Anyone with more infos?

Simply assign nil to a interface pointer and the VCL will call
Release for you in the background.

Andreas Schmidt

Re:Correct way to free IStream


"Henning Kiel" <henning.k...@rwth-aachen.de> skrev i melding
news:3D64EE4D.8050807@rwth-aachen.de...

Quote
> Hi there,
> i am using an OLE compound file, and i am wondering, what is the correct
> way to free my IStream objects.
> MS documentation says, i should call the release method, but this method
> is protected in Delphi, and i get Exceptions if i call it.
> Anyone with more infos?

var
  Stream: IStream;
begin
  Stream:=TClassThatImplementsIStream.Create;
  // Do whatever...
  // Optionally, if you want to control time of destruction:
  Stream:=nil;
  // Otherwise, it's automagically released/freed in end; block
  // *If* class is reference counting / auto-disposing, of course
end;

--
Bj?rge S?ther
bjorge@hahaha_itte.no

Re:Correct way to free IStream


Ah, thank you for the info :)

Henning

Quote
Andreas Schmidt wrote:
> Simply assign nil to a interface pointer and the VCL will call
> Release for you in the background.

Other Threads