?
Solved

Run a program on file close

Posted on 2004-09-01
6
Medium Priority
?
147 Views
Last Modified: 2011-09-20
And/or notify a program that a file has been closed

I would like to write a little program that will backup files as they are saved.  I would like this to be automatic so that any application on Windows that saves a file will notify my program and my program can take a copy.

Is this possible? if it is, how would one go about it?

Cheers,

Bob
0
Comment
Question by:doubledrat
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 375 total points
ID: 11952511
you may take a look to the ReadDirectoryChangesW-API
or look at www.torry.net for directory-monitoring components

meikl ;-)
0
 
LVL 4

Expert Comment

by:Evarest
ID: 11952538
I don't think it's a very good idea to let your program scan for _all_ saves of all programs. You might end up with a lot of junk in your backups.

You have two alternatives:

 1) Let other programs monitor all folders you need to backup.

When a certain file is changed in that folder, you can send a parameter with the path to that file to any program you like. This way, you can always wrap around a program that will do the backup, but the monitoring, you won't have to worry about anymore.
 A program that's capable of sending such dynamic parameters to any program is DirMonitor, which you can download from

http://www.download.com/DirMonitor/3000-2092-10306780.html?tag=WinTracking&part=rss&subj=newwin

 2) Do the monitoring yourself:
Create a program that will monitor folders for changes, log these changes and every now and then backup the modified files.
This will involve you writing a program that monitors AND a program that does the backups. Enjoy :-)

 3) If you really want to check every program for savings, you might try out hooks. I don't know whether there is a message when something saves data.
Another possibility is a shellnotify, but in my experience, these tend to be inaccurate and memoryleaking tools. Shellnotify will execute an event when a file is changed or modified in Explorer (thus your computer)...

Evarest
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 11952539
more explicit pointing to vcls

http://www.torry.net/pages.php?id=252
0
 
LVL 3

Expert Comment

by:gandalf_the_white
ID: 11970555
maybe this is too simple:

if you know which directories should be saved by your program (i doubt
you want to save all windows files that are changing all the time) then you can
generate a list of the files with their dates (creation and modified).
start a check every 5 minutes or so and then copy
all changed or new files.

if you make the interval quite short there will be a very small possibility that a
file is not saved before the hard drive breaks down (as the break downs don't
happen too often ;-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question