Discussion:
WaitForSingleObject on a file handle?
(too old to reply)
HTTBird
19 years ago
Permalink
On Windows XP SP2 and/or Windows Server 2K3, is it possible to use
WaitForSingleObject on a file handle to wait for a file change?
Scherbina Vladimir
19 years ago
Permalink
Post by HTTBird
On Windows XP SP2 and/or Windows Server 2K3, is it possible to use
WaitForSingleObject on a file handle to wait for a file change?
no
--
Vladimir
Scott McPhillips [MVP]
19 years ago
Permalink
Post by HTTBird
On Windows XP SP2 and/or Windows Server 2K3, is it possible to use
WaitForSingleObject on a file handle to wait for a file change?
Use ReadDirectoryChangesW in overlapped mode. WaitForSingleObject can
wait on the event in the OVERLAPPED struct.
--
Scott McPhillips [VC++ MVP]
Scherbina Vladimir
19 years ago
Permalink
Then he should remember that ReadDirectoryChangesW is not implemented under
9x.
--
Vladimir
Post by Scott McPhillips [MVP]
Post by HTTBird
On Windows XP SP2 and/or Windows Server 2K3, is it possible to use
WaitForSingleObject on a file handle to wait for a file change?
Use ReadDirectoryChangesW in overlapped mode. WaitForSingleObject can
wait on the event in the OVERLAPPED struct.
--
Scott McPhillips [VC++ MVP]
Ivan Stambuk
19 years ago
Permalink
Post by Scherbina Vladimir
Then he should remember that ReadDirectoryChangesW is not implemented under
9x.
An interesting note on "evilness" of ReadDirectoryChangesW:

http://blogs.msdn.com/ericgu/archive/2005/10/07/478396.aspx
Rod
19 years ago
Permalink
On Sun, 18 Jun 2006 04:10:40 GMT "Ivan Stambuk" <***@gmail.com> wrote:

Hi Scherbina.

Would you know why "ReadDirectoryChangesW" can report the one change to the one
file several times?

I have put together a program which monitors a directory and ONE particular text
file in that directory. When I alter that file <using a text editor>,
"ReadDirectoryChangesW" reports that ONE change several times.

I remember reading, on the net, something about this behaviour but I can't
recall where I read it or what it said. (It was while I was researching and a
few weeks before I actually began coding.)

Regards,

Rod.

:> Scherbina Vladimir wrote:
:> > Then he should remember that ReadDirectoryChangesW is not implemented under
:> > 9x.
:>
:> An interesting note on "evilness" of ReadDirectoryChangesW:
:>
:> http://blogs.msdn.com/ericgu/archive/2005/10/07/478396.aspx

__ Rod.
Rod
19 years ago
Permalink
On Mon, 19 Jun 2006 17:28:31 +1000 Rod <***@end.of.message> wrote:

Apologies,
that should read "Hi Ivan" not "Hi Scherbina".

Regards,

Rod.

:> On Sun, 18 Jun 2006 04:10:40 GMT "Ivan Stambuk" <***@gmail.com> wrote:
:>
:> Hi Scherbina.
:>
:> Would you know why "ReadDirectoryChangesW" can report the one change to the one
:> file several times?
:>
:> I have put together a program which monitors a directory and ONE particular text
:> file in that directory. When I alter that file <using a text editor>,
:> "ReadDirectoryChangesW" reports that ONE change several times.
:>
:> I remember reading, on the net, something about this behaviour but I can't
:> recall where I read it or what it said. (It was while I was researching and a
:> few weeks before I actually began coding.)
:>
:> Regards,
:>
:> Rod.
:>
:> :> Scherbina Vladimir wrote:
:> :> > Then he should remember that ReadDirectoryChangesW is not implemented under
:> :> > 9x.
:> :>
:> :> An interesting note on "evilness" of ReadDirectoryChangesW:
:> :>
:> :> http://blogs.msdn.com/ericgu/archive/2005/10/07/478396.aspx
:>
:> __ Rod.

__ Rod.
Rod
19 years ago
Permalink
Hi Ivan.

Would you know why "ReadDirectoryChangesW" can report the one change to the one
file several times?

I have put together a program which monitors a directory and ONE particular text
file in that directory. When I alter that file <using a text editor>,
"ReadDirectoryChangesW" reports that ONE change several times.

I remember reading, on the net, something about this behaviour but I can't
recall where I read it or what it said. (It was while I was researching and a
few weeks before I actually began coding.)

:> :> Scherbina Vladimir wrote:
:> :> > Then he should remember that ReadDirectoryChangesW is not implemented under
:> :> > 9x.
:> :>
:> :> An interesting note on "evilness" of ReadDirectoryChangesW:
:> :>
:> :> http://blogs.msdn.com/ericgu/archive/2005/10/07/478396.aspx
:>
:> __ Rod.

__ Rod.

HTTBird
19 years ago
Permalink
Post by Scott McPhillips [MVP]
Post by HTTBird
On Windows XP SP2 and/or Windows Server 2K3, is it possible to use
WaitForSingleObject on a file handle to wait for a file change?
Use ReadDirectoryChangesW in overlapped mode. WaitForSingleObject can
wait on the event in the OVERLAPPED struct.
--
Scott McPhillips [VC++ MVP]
Can ReadDirectoryChangesW read changes for a single file?
William DePalo [MVP VC++ ]
19 years ago
Permalink
Post by HTTBird
Can ReadDirectoryChangesW read changes for a single file?
No in the sense that it reports all changes that occur within a directory.

Yes in the sense that you can choose to ignore what does not interest you.

Maybe if a directory contains only one file, the one that you are interested
in. :-)

Regards,
Will
Kellie Fitton
19 years ago
Permalink
Hi,

You can also use the API WaitForSingleObject() to wait on a file
change if you use the following change notification function:

FindFirstChangeNotification()

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/findfirstchangenotification.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/waitforsingleobject.asp

Hope these information helps,

Kellie.
Loading...