PDA

Click to See Complete Forum and Search --> : Flushing .ini cache question


cplatts
Jul 28th, 2000, 03:38 PM
Hi

I'm altering another program's .ini file settings programmatically from within my vb6 project. Here's how I want things to go:

1) Back-up the program's ini file
2) Change .ini file settings
3) Start up the target program
4) Close target program
5) Restore the original ini file's settings.

However, the program is attempting to store its settings to the ini file on exit. As I understand it, writes to ini files using the API are cached by Windows, and there is a delay between the call being made, and the file being updated.

Is there any call that can be made which will flush the write cache and ensure that all pending changes have been committed? I could perform this between steps 4 and 5.

What's happening at the moment is that I'm closing the program, then restoring the original settings. The program's current settings (i.e. the ones I set in step 2)then get saved after step 5, effectively undoing the restoration, and leaving the ini file with the settings in step 2.

Am I going to just have to stick in a delay between closing the program and restoring the settings? I was hoping for something a bit more elegant than that :) If I *do* have to just put in a delay, how long should it be?

Any advice appreciated!