Page 1 of 1

Determine what caused dir change

Posted: Fri Feb 14, 2020 5:23 am
by BarryG
Hi all, using the code below, how can I tell if #FILE_NOTIFY_CHANGE_SIZE was triggered instead of #FILE_NOTIFY_CHANGE_FILE_NAME? Thanks.

Code: Select all

Debug #FILE_NOTIFY_CHANGE_SIZE ; 8

Repeat
  Sleep_(250)
  dir=FindFirstChangeNotification_("D:\Temp\",0,#FILE_NOTIFY_CHANGE_FILE_NAME|#FILE_NOTIFY_CHANGE_SIZE)
  Repeat
    why=WaitForSingleObject_(dir,#INFINITE)
    a+1
  Until a=3
  a=0
  Debug why ; 0 (I was hoping 8)
  FindCloseChangeNotification_(dir)
ForEver

Re: Determine what caused dir change

Posted: Fri Feb 14, 2020 7:15 am
by Mijikai
It wont wait for both or one specific event.
A wait is satisfied when one of the filter conditions occurs in the monitored directory or subtree.
To wait for the next event call FindNextChangeNotification_(), however i didnt find a simple way to see what event specifically was triggered.

Re: Determine what caused dir change

Posted: Fri Feb 14, 2020 7:48 am
by BarryG
It triggers on both, but I was hoping to detect which it was that triggered, without looping through and querying all the files in the folder.

Re: Determine what caused dir change

Posted: Fri Feb 14, 2020 8:05 am
by Mijikai
ReadDirectoryChangesW migh be an option.