当前位置: 动力学知识库 > 问答 > 编程问答 >

delphi - 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 solutions 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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: