views:

93

answers:

3

I have to write a litle app that will process files saved in a given dir. I doesn´t pleases me the idea of writing infinite loops, timers and that kind of stuff.

I´d like to know if there if (I would bet a finger that there is!) there is any windows API that would send my app a message for any file saved in that given dir.

+2  A: 

The function you're looking for is ReadDirectoryChangesW.

Meta
Alternatively, FindFirstChangeNotification() and/or SHChangeNotifyRegister() can be used as well.
Remy Lebeau - TeamB
+2  A: 

ReadDirectoryChangesW is non-trivial to use correctly. There is a working sample here. I have worked with production code closely derived from this, and I've found no better sample to work from.

Note that there are known issues with the API (admittedly corner cases that may not affect you) that are described here and here, and further suggestions on usage here.

Steve Townsend
4 out of 5 links broken! And the answer is just 2 hours old...
Romulo A. Ceccon
Yes that sucks. I will fix this.
Steve Townsend
Fixed links, one website appears to be broken so I removed that
Steve Townsend
+2  A: 

you can use the FindFirstChangeNotification funciton too. Exist an component called TJvChangeNotify from the JEDI JVCL collection wich encapsules this function which makes it easier to use.

RRUZ