Re: FILE_SHARE_READ and FILE_SHARE_WRITE
From: Gary Chanson (gchanson_at_No.Spam.TheWorld.net)
Date: 06/30/04
- Next message: Mark Shay: "Re: Trying to use GetProcAddress to call a function in a DLL using Vis"
- Previous message: Gary Chanson: "Re: pipes in C++"
- In reply to: PEACEMAKER: "FILE_SHARE_READ and FILE_SHARE_WRITE"
- Next in thread: hector: "Re: FILE_SHARE_READ and FILE_SHARE_WRITE"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 30 Jun 2004 13:39:27 -0400
"PEACEMAKER" <do.not.email@yo.mamas.hairy.ass.com> wrote in message
news:%236ZrErrXEHA.3044@TK2MSFTNGP09.phx.gbl...
> I have an application that needs to be able to open any file for reading.
> Currently I only use FILE_SHARE_READ but I looking at the docs it mentions
> that if a file was opened by another processes with FILE_SHARE_WRITE then
> all subsequent open operations on the file has to include this flag or
> opening will fail (eg if I only specificy FILE_SHARE_READ). The docs don't
> say what happens in the reverse case.. eg a file is created with
> FILE_SHARE_READ, but I attempt to open it with
> FILE_SHARE_READ|FILE_SHARE_WRITE.
Not quite. The file sharing flags determine what file modes are
permitted to other handles to the same file object. In other words, if I
open a file with FILE_SHARE_READ, the file can also be opened for read by
another call to open. If I specify FILE_SHARE_WRITE, the file can be opened
for write by another call. If I specify neither, the file cannot be opened
by another call. Any subsequent open has to specify whatever flags are
needed to account for my open mode. If I open the file for read, they must
specify FILE_SHARE_READ and so on.
> Which flags should I use to be able to
> open all shared files without any problems?
This isn't possible. The best you can do is to specify both
FILE_SHARE_READ and FILE_SHARE_WRITE. This will permit you to open any file
for reading which has specified FILE_SHARE_READ but you will still not be
able to open files opened in exclusive mode.
-- -GJC [MS Windows SDK MVP] -Software Consultant (Embedded systems and Real Time Controls) - http://www.mvps.org/ArcaneIncantations/consulting.htm -gchanson@mvps.org
- Next message: Mark Shay: "Re: Trying to use GetProcAddress to call a function in a DLL using Vis"
- Previous message: Gary Chanson: "Re: pipes in C++"
- In reply to: PEACEMAKER: "FILE_SHARE_READ and FILE_SHARE_WRITE"
- Next in thread: hector: "Re: FILE_SHARE_READ and FILE_SHARE_WRITE"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|