I want to catch the changes of a file (time or size) in c++, but not with timer, i want to start a code automatically when the file is changed. Is there any possibilities for this in c++?
Did you check out the documentation I mentioned? I guess not, since there is nothing with timers there...
----------------------------------
Basic idea:
1)
You call FindFirstChangeNotification with some parameters/filters.
2)
Then you wait for the notifications to arrive, using WaitForSingleObject or WaitForMultipleObjects (if you for example want to listen changes in more than one directory).
You could put this in a while loop to keep on listening.
----------------------------------
Since your code will stand and wait it will "hang" your application.
Solution: Put the above mentioned stuff in a separate thread...
I reapeat, check out the articles in MSDN regarding FindFirstChangeNotification
/Per Nerdy signatures are as lame as the inconsistent stardates of STTNG.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.