Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
Back to article list Search Articles Add Comment Printer friendly Direct link Par2: Monitor folder for changes 2012-03-15 -- Bjarne Havnen waitforsingleobject(unsigned,long),raw,long,pascal,name('waitforsingleobject'),proc
WaitForMultipleObjects(long,long,long,long),raw,long,pascal,proc
FindFirstChangeNotification(*cstring,
bool,long),raw,unsigned,pascal,name('FindFirstChangeNotificationA')
FindNextChangeNotification(unsigned),raw,bool,pascal,name('FindNextChangeNotification'),proc
FindCloseChangeNotification(unsigned),raw,bool,pascal,name('FindCloseChangeNotification'),proc
I start a procedure on a separate thread. Then I call the below method which is wrapped up in a class.
When I change happens, I call a
TakeChange method which just use regular DIRECTORY to get content and process it.
I've made some slight modifications which should enable you to test it, to get an idea...
Call as
WaitChange(yourdirectory,,FILE_NOTIFY_CHANGE_FILE_NAME)
The constants are defined in svapi.inc
WaitChange PROCEDURE (string pDir,Byte subdir=false,Long FILE_NOTIFY_CHANGE) ! Declare Procedure
Notifhandle long
Autoreset Byte
waitdir cstring(file:Maxfilepath)
Invalid_handle_Value equate(-1)
CODE
waitdir = clip(pdir)
NotifHandle=findFirstchangeNotification(waitdir,subdir,FILE_NOTIFY_CHANGE)
If NotifHandle = INvalid_Handle_value
Return
End
Loop
Autoreset = False
!if waitstruct.notifhandle has becomes signaled then send a message
case waitForMultipleObjects(1,address(notifhandle),0,10000)
Of Wait_object_0
if Message('change
happened','change',,button:ok+button:cancel)=Button:Cancel
Break
Else
Autoreset = true
end
Of WAIT_TIMEOUT
if Message('timeout
happened','change',,button:ok+button:cancel)=Button:Cancel
Break
Else
autoreset = true
End
end
If AutoReset
FindNextchangeNotification(notifhandle)
Cycle
End
Break
end !sleep again if reset
FindCloseChangeNotification(NotifHandle)
Today is November 23, 2024, 2:07 am This article has been viewed 35250 times.
|
|