Question

I am using this implementation of ReadDirectoryChangesW to monitor changes to the desktop. My program plans to run some small program when a file is created on the desktop.

Now the problem I am running into is when I create a new shortcut via the right click context menu ReadDirectoryChangesW gets a notification saying the file has been created, but right after it gets another notification saying the file has been deleted. I have been running into this problem since Windows Vista.

Anyone have any idea what could be wrong? Is there another function I should be using to monitor directory changes specific to Vista and 7?

Thanks, Krishna

Was it helpful?

Solution 3

I managed to resolve this issue. I still don't know why I am getting all those strange ReadDirectyChangesW events but I got my end result so I am leaving this question be.

Thanks for all the help.

OTHER TIPS

Windows does some funny stuff with .lnk files so that you can't see the .lnk extension. Maybe that's why the deleted notification gets sent, because Windows itself can't see the "New Shortcut.lnk" file, only the "New Shortcut". But this is just a theory.

So what I would do is try to work around it, and ignore the file-deleted notification if the file still exists. Assuming you can figure out that the .lnk file does still exist of course :)

Have you defined any filters: you might be seeing the shortcut being recreated (and not matching your filter).

Explorer tends to create things with a fixed name, and then rename them. So ReadDirectoryChangesW will see multiple changes.

Additional thoughts:

Note, the buffer with the change notification can contain multiple notifications, are all being read.

What does Process Monitor show at the same time?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top