Solved

Run a program on file close

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

15 Experts available now in Live!

Get 1:1 Help Now