Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Run a program on file close

Posted on 2004-09-01
6
140 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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