Delphi notification when updating a file

My application contains documents in its database. Users can open documents, in which case the document is saved in a temporary folder and opened on the user computer.

I want to be notified when one of these temporary files is changed, and will prompt the user to save the changed document back to the database.

What is the easiest way to do this in Delphi7? (I assume that this requires some kind of shell magic or a third-party component)

Thanks!

+6
shell file-io winapi delphi delphi-7
source share
4 answers

You can:

  • use the Win32 API function SHChangeNotifyRegister to monitor changes in the temp folder and then check your feedback if your temporary files report changes.

  • since you know the exact file (s) that interests you, you can manually control them directly to resize them and timestamps using FindFirstFile in a timer or stream.

+4
source share

You can detect changes in temporary files (or any file) using the TJvChangeNotify component from the JEDI JVCL collection .

+8
source share

In addition to what RRuz and Remy Lebeau wrote:

Note that TJvChangeNotify in the JvChangeNotify module uses the FindFirstChangeNotification API call; this is the MSDN documentation. Note that this is a little contrary to intuition: see the thread below on how to use it inside a while loop.

There is also a call to the ReadDirectoryChanges API, which is not wrapped by JCL / JVCL and has MSDN documentation here and there is an example of Delphi win32 .

This thread explains the differences between the two API calls.

- Jeroen

+4
source share

Also take a look at this: http://www.cromis.net/blog/downloads/directory-watch/ and How to control the directory for files in Delphi XE?

+2
source share

All Articles