有没有一种方法可以查看是否正在使用tfile流的实例?例如,如果我声明了tfilestream类型的FS,向它写缓冲区,最后使用tfilestream.free释放流,我可以检查以下内容:
if
tfilestream.NotActive
then
//code
if tfilestream.beingused then
//code
if tfilestream.free = true then
//codeactive和被使用的方法并不是真实存在的,我们也不能测试tfilestream.free = true,只是为了了解我想要问的是什么。
发布于 2010-07-27 17:04:51
你不能按你预期的方式去做。但是你和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;https://stackoverflow.com/questions/3345905
复制相似问题