When an application creates a new file or opens an existing file, it must specify whether it wants to share the file for reading, writing, both, or neither. This is known as the sharing mode.
In the table below, on the left hand side select the row with the Generic Read and /or Write access that your process requires, then select the column with the File Sharing mode to see what other activity will then be able to co-exist with your process.
The file sharing is a two way street - to be compatible, both processes must have FILE_SHARE settings that are compatible with whatever the other process needs. If they don’t have compatible sharing modes then the file will be locked by the first process.
For example if your process needs GENERIC_WRITE access to a file and you want it to co-exist with other processes that have FILE_SHARE_READ sharing mode, then you can see that this will work providing those other processes share the file with a GENERIC_READ process that in turn has enabled FILE_SHARE_WRITE.
|< The file_share bits indicate what you want to allow other processes to do.|
|GENERIC_READ||Share with any READ process that has File_Share_Read||Share with any WRITE process that has File_Share_Read||Share with any other process that has File_Share_Read|
|GENERIC_WRITE||Share with any READ process that has File_Share_Write||Share with any WRITE process that has File_Share_Write.||Share with any other process that has File_Share_Write|
|Share with any READ process that has File_Share_Read + File_Share_Write||Share with any WRITE process that has File_Share_Read + File_Share_Write||Share with any other process that has File_Share_Read + File_Share_Write|
|^ The Generic_access bits indicate what your process needs to do.|
Each row in the table above has the same permission, the only tricky part is remembering the difference between GENERIC_READ and FILE_SHARE_READ etc.
"plus ça change, plus c'est la même chose (The more things change, the more they are the same)” ~ Jean-Baptiste Alphonse Karr 1849.
Creating and Opening Files - docs.microsoft.com
How do the FILE_SHARE_* bits interact with the desired access bits? - Raymond Chen [MSFT]