DelphiFAQ Home Search:
General :: Windows :: Programming :: Windows with Delphi :: Windows Filesystem
File related questions and answers. File operations, attributes, system dialogs, hard disk handling.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

This is the FULL list of all articles in this category.

Featured Article

Detecting File Accesses

Question:

In a program that I'm writing, I need to know when any file is opened or saved and what the name of that file is. Is there an easy way to make a hook procedure with the Windows API or messages?

Answer:

Yes, the Windows operating system does offer such a hook, at least in Windows NT 4.0 and in Windows 2000. The following should also work with Windows 98/ ME.

You could dig through the Windows API files, but luckily there is also an easier way to accomplish this task – use the excellent free component library RxLib. It contains a component that does exactly the desired function.The name of this component is TRxFolderMonitor.
I have used this TRxFolderMonitor component in one network application and it worked really great - no need to dig in the source.

You simply put a TRxFolderMonitor component on your form and assign the Directory property the directory which you need to monitor. You can even tell the component to monitor subdirectories (recursively)!

TRxFolderMonitor will create a thread for you that gets activated in the even of a detected change.