Files Delphi

Title: How get notifications on changes at the filesystem
Question: Is is possible to get an event when the user is changing a file or folder?
Answer:
The Windows API provides some functions to set a watchdog on the filesystem.
Basically these loop will notify, if a file or folder was changed:
var
ChangeHandle: THandle;
...
ChangeHandle:= FindFirstChangeNotification(PChar(WatchPath), false,
hNotifyFilter);
if ChangeHandle INVALID_HANDLE_VALUE then
while true do
begin
if WaitForSingleObject(ChangeHandle,500) = WAIT_OBJECT_0 then
begin
// Event...
end;
FindNextChangeNotification(ChangeHandle);
end;
The component TDirWatcher is encapsulating this task in an own thread. The event OnChange fires on any change in a specified directory or subtree.