how to prevent that the OS or other programs writes on a storage device in the same time as my program does
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.
精彩评论