Try it yourself:
Create an XLS file, open it in Excel.
Open sysinternals Process Monitor, and watch what happens while you make a copy of your XLS file in the explorer (just hit ctrl-c ctrl-v).
Two calls to ::CreateProcess
in a row. First call asks for read permissions, and gets Access denied. Second call asks for read plus write plus delete and passes.
Is that normal?
If you open a file with FILE_SHARE_READ
you're saying you're willing to share access to this file, but only for reads.
If you open with all the flags, you're willing to share access also for writes/delete.
FILE_SHARE_READ
is more restrictive than FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE
If some other process (excel) has this file opened for e.g. write (and it has the sharing flags set), the only way you can access it is to accept sharing it for write.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With