How to block a file on Windows?
How to lock a file in Windows so that this file can only be opened / read / written by one process?
I found out that a file can be locked by CreateFile
pointing 0
to dwShareMode
. It works, but only the processed descriptor can be used to operate on the file. But I want to be able to lock the file for other processes and at the same time create multiple handles in my process.
Please help me to solve this problem or give some advice ...
a source to share
I don't think you can do this. The closest you can use CreateFile
to open / lock a file the first time and then use DuplicateHandle
to create multiple handles from what you already have
a source to share