本文介绍了如何检测tfilestream是否已释放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有办法查看是否正在使用tfile流实例?例如,如果我声明了类型为tfilestream的FS的,则向其写入缓冲区,然后最终使用tfilestream.free释放流。我可以检查一下吗?
is there a way to see if an instace of tfile stream is being used? for example if i declare FS of type tfilestream,write buffer to it and finally free the stream using tfilestream.free can i check something like:
if tfilestream.NotActive then //code if tfilestream.beingused then //code if tfilestream.free = true then //codeactive 和 beingused 方法不存在,我们也无法测试 tfilestream.free = true 只是为了弥补这一点,以了解我要问的问题
active and beingused methods do not exists for real nor can we test tfilestream.free = true just making this up to give idea what i am trying to ask
推荐答案您无法以预期的方式进行操作。但是您可以使用 FreeAndNil()
You can't do it in the way you expect. But you and do it with FreeAndNil()
var FS : TFileStream; begin FS := TFileStream.Create(...); try // Do Work with TFileSTream finally FreeAndNil(FS); end; // For some reason you need to check FS is freed. if not Assigned(FS) then begin // Stream was freed. end; end;更多推荐
如何检测tfilestream是否已释放?
发布评论