Determine what caused dir change

Windows specific forum
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Determine what caused dir change

Post 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
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Determine what caused dir change

Post 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.
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: Determine what caused dir change

Post 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.
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Determine what caused dir change

Post by Mijikai »

ReadDirectoryChangesW migh be an option.
Post Reply