So, the question is: I get some notifications I don’t want to get. But I don’t know for what file/dir I got them. Is there a way to know why given notification was fired?
If you think about ReadDirectoryChangesW, please include a meaningful code sample.
If you would like Windows to tell you what specific file or subdirectory changed, you will need to use ReadDirectoryChangesW. The asynchronous mode is fairly simple if you use a completion routine.
On the other hand, you will probably get better performance by using the slightly more complicated I/O completion ports approach. I would recommend downloading Wes Jones’ excellent CDirectoryChangeWatcher source code as a starting point. There are several gotchas that his code will help you avoid, particularly in parsing the
FILE_NOTIFY_INFORMATIONrecords.