Questions of a technical nature will be ignored due to ignorance on my part.

Comments, suggestions, improvements and (if this is not good or safe) warnings are requested.
Hope it is ok, and hope it is useful.
Code: Select all
; Monitor changes to a folder, by Dare2
; First test
; Windows 2K and PB3.91
;
; Change "pth" var below to hold a folder name
; Do something to the folder, eg,
; Copy in a file then delete it.
;
; If your windows are crowded you might
; have to hunt for the messagebox! :)
#STATUS_WAIT_0=$00000000 ; Taken from windows inc
#STATUS_ABANDONED_WAIT_0=$00000080 ; Not all are used here.
#STATUS_USER_APC=$000000C0
#STATUS_TIMEOUT=$00000102
#WAIT_FAILED=-1
#WAIT_OBJECT_0=#STATUS_WAIT_0
#WAIT_ABANDONED=#STATUS_ABANDONED_WAIT_0
#WAIT_ABANDONED_0=#STATUS_ABANDONED_WAIT_0
#WAIT_TIMEOUT=#STATUS_TIMEOUT
#WAIT_IO_COMPLETION=#STATUS_USER_APC
fHnd.l
; Decide which notifications
flgs=0
flgs=flgs | #FILE_NOTIFY_CHANGE_FILE_NAME
flgs=flgs | #FILE_NOTIFY_CHANGE_FILE_NAME
flgs=flgs | #FILE_NOTIFY_CHANGE_DIR_NAME
flgs=flgs | #FILE_NOTIFY_CHANGE_ATTRIBUTES
flgs=flgs | #FILE_NOTIFY_CHANGE_SIZE
flgs=flgs | #FILE_NOTIFY_CHANGE_LAST_WRITE
flgs=flgs | #FILE_NOTIFY_CHANGE_SECURITY
pth.s="C:\aFolder\path\required\"
fHnd=FindFirstChangeNotification_(pth,#False,flgs)
If fHnd=#INVALID_HANDLE_VALUE
MessageRequester("ERROR","FirstChange returned "+Str(GetLastError_()),#MB_ICONSTOP)
End
EndIf
; Only watches for 1 minute or 2 events, which is sooner.
timeout=60000
tm=GetTickCount_()+timeout
While ctr<2 And tm>GetTickCount_()
res.l=FindNextChangeNotification_(fHnd) ; Advise we want a notification
If res=#False
MessageRequester("ERROR","NextChange returned "+Str(GetLastError_()),#MB_ICONSTOP)
ctr=3
Else
; Wait for notification
chng=WaitForSingleObject_(fHnd,timeout) ;#INFINITE)
ctr+1
If chng=#WAIT_OBJECT_0
MessageRequester("NOTICE!","Change Notification!",#MB_ICONEXCLAMATION)
Else
MessageRequester("NOTICE!","ANOTHER EVENT!",#MB_ICONSTOP)
EndIf
res.l=FindNextChangeNotification_(fHnd)
If res=#False
MessageRequester("ERROR","NextChange returned "+Str(GetLastError_()),#MB_ICONSTOP)
ctr=3
EndIf
EndIf
Wend
res=FindCloseChangeNotification_(fHnd)
WaitForMultipleObjects_(count,AddressOfArrayOfHandles,#False,timeout)