Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Watch (Monitor) a Directory

Keywords:    watchdir watch a directory monitor a folder

You can monitor a directory, and get a notice if anything changes in it. (Which would include a file being deleted.)

This code does it...


WatchDir = (The directory you want to watch)

Kernel32 = DllLoad(strcat(dirwindows(1),"KERNEL32.DLL"))
WatchHandle = DLLCALL(Kernel32,long:"FindFirstChangeNotificationA",lpstr:WatchDir,long:1,long:1)
Status = DLLCALL(kernel32,long:"WaitForSingleObject",long:WatchHandle,long:-1)
DLLCALL(Kernel32,long:"FindCloseChangeNotification",long:WatchHandle)
DllFree(Kernel32)

Message ("Hello!","Something Changed!")

Article ID:   W15287