Re: Strange problem with ReadDirectoryChangesW()

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks for the response Terry!

"Terry" <terry999@xxxxxxxxxxxxx> wrote in message
news:uOIO9ypRFHA.3704@xxxxxxxxxxxxxxxxxxxxxxx
> Could it be that ReadDirectoryChangesW() is returning 0, and you skip over
> doing anything about that, and loop back to calling
ReadDirectoryChangesW()?
> If it returns 0, that means there is an event ready but the buffer was too
> small, so the event is still waiting to be retrieved... pass it bigger
> buffers until it succeeds.

This sounds plausible - but is this how it works? The docs for
ReadDirectoryChangesW() say that if it returns 0 it means the buffer was too
small, and that you have to re-read the directory yourself manually to work
out what changed.

If the original call to ReadDirectoryChangesW() was done asynchronously, and
I get back 0 to the completion routine, can I then call
ReadDirectoryChangesW() _synchronously_ on the same handle to read the data
(passing bigger and bigger buffers)?

Alternatively, if I just closed the file handle in this point would this
"flush" the queued file changes?

Finally, do you have any idea what the "DELETE PEND Change Notify" event in
FileMon actually means?

Thanks so much,
Jon





>
> "Jonathan Potter" <greg@xxxxxxxxxxxxx> wrote in message
> news:#trRNbnRFHA.3988@xxxxxxxxxxxxxxxxxxxxxxx
> > Hi people,
> >
> > In our application we have to monitor practically the whole file system
> for
> > changes, so we set up file notification on all fixed drives using
> > ReadDirectoryChangesW().
> >
> > Basically we open a handle to the root of the drive, start notification
on
> > it (using overlapped IO), wait for an event, read any changes into a
> buffer,
> > and then restart notification again.
> >
> > Most of the time there is no problem with this (although the fundamental
> > flaw is of course that a change can be missed in between reading the
> > returned data and restarting notification - anyone know a good way
around
> > this?)
> >
> > The problem we are having is that very rarely our program will go into
an
> > endless loop, with the notification returning as soon as it is started.
> >
> > Looking at what is going on in FileMon we see an endless stream of
events
> on
> > a folder in the recycle bin (which we are not touching) - the event is
> > categories as "DELETE PEND Change Notification".
> >
> > Does anyone have any idea what could be going on here? What does DELETE
> PEND
> > mean? Where are these events coming from and what is causing
> > ReadDirectoryChangesW() to return an endless stream of them?
> >
> > Thanks all,
> > Jon
> >
> >
>
>


.



Relevant Pages

  • Re: Strange problem with ReadDirectoryChangesW()
    ... and loop back to calling ReadDirectoryChangesW? ... Basically we open a handle to the root of the drive, start notification on ... ReadDirectoryChangesW() to return an endless stream of them? ...
    (microsoft.public.win32.programmer.kernel)
  • Re: FileSystemWatcher across the network
    ... ReadDirectoryChangesW API. ... specify a buffer that the OS will populate with the changes. ... Heavy-weight solutions would be to write a dedicated file system filter ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Strange problem with ReadDirectoryChangesW()
    ... and loop back to calling ReadDirectoryChangesW()? ... > Basically we open a handle to the root of the drive, start notification on ... > ReadDirectoryChangesWto return an endless stream of them? ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Strange problem with ReadDirectoryChangesW()
    ... As a follow up Terry, I set the buffer size I was using to something ... >> Could it be that ReadDirectoryChangesW() is returning 0, ... so we set up file notification on all fixed drives using ...
    (microsoft.public.win32.programmer.kernel)
  • Re: FileSystemWatcher across the network
    ... didn't state very clear about the buffer size when monitoring network path. ... It's recommended not exceeds 64K when monitoring network path. ... ReadDirectoryChangesW API. ... Heavy-weight solutions would be to write a dedicated file system filter ...
    (microsoft.public.dotnet.languages.vb)