No announcement yet.

can an app detect when another app is about to write a file?

  • Filter
  • Time
  • Show
Clear All
new posts

  • can an app detect when another app is about to write a file?

    Following my question about keypresses and mouse events, it seems logical to extend the enquiry to writing to a file. If I can detect when an application (which knows nothing about it) writes to a file, then I can possibly "mirror" the file. Or am I dreaming?

  • #2
    "About to write" ... No.

    "Has written"... maybe. If file is closed after write, FindFirstChangeNotification loop can signal your program and you can 'do something.'

    Or maybe the file need not be closed... under FFCN doc we find
    FILE_NOTIFY_CHANGE_LAST_WRITE Any change to the last write-time of files in the watched directory or subtree causes a change notification wait operation to return. The operating system detects a change to the last write-time only when the file is written to the disk. For operating systems that use extensive caching, detection occurs only when the cache is sufficiently flushed.
    Similar notation under option FILE_NOTIFY_CHANGE_SIZE.

    For some reason I have always thought the file has to be closed to result in either one of these notifications to be issued... but I guess testing could determine that.

    I don't know there is a "hook" or anything to detect when WriteFile() or any other function is called.

    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]