Windows supports LockFile function for applying exclusive locks on a file, and the LockFileEx functions for applying an exclusive locks and shared read for all processes.
Is it possible to have ProcessA apply an exclusive lock, and then allow Only ProcessA And ProcessB to read the file, while at the time, no other process - outside those two processes - would have read access on the locked file?
According to the Doc:LockFileEx function
In my opinion, Exclusive lock doesn't allow read and write operations.Shared lock allows only read operation.
If the file is set
Exclusive lockwith LockFileEx function, all other processes will be denied both read and write access. If the file is setShared lockwith LockFileEx function, all processes can read the locked region. If the file is setshared lockandexclusive lockat the same time, the only possible access is a read by the owner of the locks.