Monitors a directory for file changes in a seperate thread.

FindFileChange(cDirectory, bWatchSubtree, nFilter, cCallback)

Parameters

cDirectory

The full path of the directory to be watched. This cannot be a relative path or an empty string.
The name is limited to MAX_PATH (260) characters.

bWatchSubtree

If this parameter is .T., the function monitors the directory tree rooted at the specified directory; if it is .F., it monitors only the specified directory.

nFilter

The filter conditions that satisfy a change notification. This parameter can be one or more of the following values.

ValueMeaning
FILE_NOTIFY_CHANGE_FILE_NAMEAny file name change in the watched directory or subtree causes a change notification wait operation to return. Changes include renaming, creating, or deleting a file name.
FILE_NOTIFY_CHANGE_DIR_NAMEAny directory-name change in the watched directory or subtree causes a change notification wait operation to return. Changes include creating or deleting a directory.
FILE_NOTIFY_CHANGE_ATTRIBUTESAny attribute change in the watched directory or subtree causes a change notification wait operation to return.
FILE_NOTIFY_CHANGE_SIZEAny file-size change in the watched directory or subtree causes a change notification wait operation to return. The operating system detects a change in file size only when the file is written to the disk. For operating systems that use extensive caching, detection occurs only when the cache is sufficiently flushed.
FILE_NOTIFY_CHANGE_LAST_WRITEAny change to the last write-time of files in the watched directory or subtree causes a change notification wait operation to return. The operating system detects a change to the last write-time only when the file is written to the disk. For operating systems that use extensive caching, detection occurs only when the cache is sufficiently flushed.
FILE_NOTIFY_CHANGE_SECURITYAny security-descriptor change in the watched directory or subtree causes a change notification wait oper
cCallback

The function to call when one of the filter conditions occur in the monitored directory or subtree.
The function should have to following signature:

FUNCTION FolderChanged
    LPARAMETERS hHandle, cPath, nError
    IF nError = 0
        ? cPath + ' changed'
    ELSE
        ? 'Function: ' + cPath + " failed. ErrorNo. ", nError
    ENDIF		
ENDFUNC

Return Value

A numeric handle representing the thread which monitors the directory.

See Also

Reference

ADirectoryInfo
ADirEx
ADriveInfo
AFileAttributes
AFileAttributesEx
CancelFileChange
CompareFileTimes
CopyFileEx
DeleteDirectory
DeleteFileEx
GetFileAttributes
GetFileOwner
GetFileSize
GetFileTimes
GetLongPathName
GetShortPathName
MoveFileEx
SetFileAttributes
SetFileTimes

Used WinApi functions

FindFirstChangeNotification
FindNextChangeNotification
CreateThread
WaitForMultipleObjects
PostMessage