Watch the subtree for directory creation and deletion.įILE_NOTIFY_CHANGE_DIR_NAME) // watch dir name changes Printf("\n ERROR: FindFirstChangeNotification function failed.\n") If (dwChangeHandles = INVALID_HANDLE_VALUE) Watch the directory for file creation and deletion.ĭwChangeHandles = FindFirstChangeNotification(įILE_NOTIFY_CHANGE_FILE_NAME) // watch file name changes _tsplitpath_s(lpDir, lpDrive, 4, NULL, 0, lpFile, _MAX_FNAME, lpExt, _MAX_EXT) This simplistic example uses the ExitProcess function for termination and cleanup, but more complex applications should always use proper resource management such as FindCloseChangeNotification where appropriate. Whenever a file is created or deleted in the directory, the example should refresh the directory. Whenever a directory is created or deleted in the tree, the example should update the entire directory tree. The example uses the FindFirstChangeNotification function to create two notification handles and the WaitForMultipleObjects function to wait on the handles. It also monitors a directory for file name changes. The following example monitors the directory tree for directory name changes. To track changes on a volume, see change journals. This function also enables you to provide a completion routine. To retrieve information about the specific change as part of the notification, use the ReadDirector圜hangesW function. Use FindCloseChangeNotification to close the notification handle. However, these functions do not indicate the actual change that satisfied the wait condition. If the wait condition is satisfied, FindNextChangeNotification can be used to provide a notification handle to wait on subsequent changes. This function also returns a handle that can be waited on by using the wait functions. The conditions include changes to file names, directory names, attributes, file size, time of last write, and security. For example, an application can use these functions to update a directory listing whenever a file name within the monitored directory changes.Īn application can specify a set of conditions that trigger a change notification by using the FindFirstChangeNotification function. When something changes within the directory being watched, the read operation is completed. Waiting for a change notification is similar to having a read operation pending against a directory and, if necessary, its subdirectories. An application can monitor the contents of a directory and its subdirectories by using change notifications.
0 Comments
Leave a Reply. |