Overview
Ever wanted to know in your program when a specific file has changed?
If yes, then this sample program is the solution to your needs: it sits silent waiting for a system notification about changes.
Description
This sample program lets you select a file to monitor and installs a listener that waits for system notifications about changes in the folder the file is in; it then checks for date and time of last update and displays new content on screen if the file has changed.
The example program has been developed to handle text files simply to have a visual effect of how it operates, nevertheless it can handle every type of file since what to do after receiving the notification is left to the programmer.
By relying on a system notification, the application consumes very little resources since it does really nothing but waiting for the notification to arrive. A timeout is provided to let the system responsive to user interaction.
The notification is handled by a separate thread to let the main program thread unaffected.
How to run this example
How to integrate the code in your application
All the code needed for this facility is located in ThreadNotify () function and can be copied in your code with the adaptations needed to accomodate it to the code structure. The section that displays file content on screen must be changed to the desired reaction to the event.
Requirements
Software
This program has been developed in LabWindows/CVI 2012SP1 Full Development System
It relies on some system APIs to work so the interface to the Win32 API must be installed.
According to this document (WARNING: it may take a *long* time to open!) the APIs used are available in every CVI version so it should be possible to run the example in base version too, however I cannot test it since I only have FDS.
Hardware
No hardware is required to run this example