Solved

Run a program on file close

Posted on 2004-09-01
6
138 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
6 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

937 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now