Q: ReadDirectoryChangeW

J

johndoe1

X-Noarchive: Yes

Friends,

I'm trying to get ReadDirectoryChangeW to pick file movement in a
directory.

I'm using the I/O completion port-based method and, the funny thing is,
I'm not getting any notifications whatsoever, no matter what I do in the
"watched" directory.

The port is fine: when I'm shutting down I'm queuing a special-purpose
packet to it and it picks it up just fine. I've played a bit with the SDK
sample "fwatch", which, after a bit of tweaking, I got to do what I need,
more or less.

Now, the only difference that I can see between my proggie and fwatch is
that in fwatch the thread that sets everything up (including iocp creation
and issuing the first RDCW call) and the thread that then waits on this
iocp are different, whereas in my case everything is done from the same
thread (my proggie is a service, so I already have my ServiceMain running
in an extra thread and don't really need yet another "worker" thread).
However, the shutdown packet that I've mentioned above is queued from a
_different_ thread (when run as service, from the ControlHandler; when run
as an app, from a SIGINT signal handler) -- and this part works just fine.

Is it possible that the waiting thread must be different from the one that
set everything up here? Any other ideas/suggestions?

Thanks.
 
J

johndoe1

X-Noarchive: Yes

As a public service: buffer alignment was the problem -- the [out] buffer
that you supply to RDCW *must* be allocated on the 4-byte boundary.
Otherwise the mechanism won't work, there'll be no notification (and no
errors either, it fails silently).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top