对不起昨天因为很晚了,没有仔细说明
使用文件系统变化通知,只要:
Uses Windows;
Var
myHandle: HANDLE;
Begin
myHandle := FindFirstChangeNotification(
'A:/',
FILE_NOTIFY_CHANGE_FILE_NAME or FILE_NOTIFY_CHANGE_DIR_NAME
or FILE_NOTIFY_CHANGE_ATTRIBUTES OR FILE_NOTIFY_CHANGE_SIZE
OR FILE_NOTIFY_CHANGE_LAST_WRITE
);
IF (myHandle<>INVALID_HANDLE_VALUE)
then
Begin
Repeat
WaitForSingleObject(myHandle);
// if there's any change happens under 'A:/';
// the following codes will be executed:
Refresh your dir?
FindNextChangeNotification(myHandle);
Until (do not want to detect changes again);
FindCloseChangeNotification(myHandle);
End;
End;
上述例子程序可能需要在一个线程中运行