开发者

how to prevent that the OS or other programs writes on a storage device in the same time as my program does

开发者 https://www.devze.com 2023-02-04 17:52 出处:网络
I\'m a Delphi programmer. I want to fill the entire free space of a storage device with dummy file(s).

I'm a Delphi programmer. I want to fill the entire free space of a storage device with dummy file(s). During this operation I want to prevent that Windows or other programs write on the device. I know it is doable because I have seen programs that do it.

I already have the code to create the dummy files (using TFileStream, very fast on NTFS) so all I need is some sort of lock/unlock code.

Does someone know a way..? Thank you for any suggestion.

I will accept even solutio开发者_高级运维ns that will change the way I create those files, provided that the entire program will work better.

Thank you.

Best regards, John.


There's a SetEndOfFile function which is presumably transactional (i.e. it either succeeds or fails), which I think (I haven't tested/checked it) you can use to grow a file to fill available space.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号