PDA

View Full Version : INI file entries erased on Cancel



alan93
12-20-2001, 04:04 PM
I am writing a key and value to an INI file. I am using ReplaceProfSting().

When Cancel is selected after this event, it erases the entire entry.

This is undesirable as the old key and value needs to be put back.

How can I accomplish this? I read about Disable(LOGGING) but that seems to only affect Uninstalls , not Cancels.

It Appears that this 'erasing' is occuring after the abort. So I am unable to do anything after this executes.

I am new to installshield.

Andy M-S
12-27-2001, 04:42 PM
Well, there's no way for IS to rewrite the line (which you replaced) on uninstall, whether logging is on or off. It doesn't keep a copy of the data that you're overwriting. The best it can do (without help) is to delete any additions it made (if logging is on).

If you're correct, and the cancellation action is significantly distinct from the uninstall action that the log isn't used (and I'm not certain that you are) then you'll have to write your own routine for handling this and place it in the OnCancelling() event handler.

Perhaps you can store the old line until installation is complete, and if the installation is cancelled, write it back to the file before aborting.

Alternatively, make a backup of the file before you edit it, and copy the backup over the installer-modified copy if the user decides to cancel.

alan93
12-27-2001, 04:48 PM
I just put the ReplaceProfSting() at the end of the install therefore not allowing the INI to be changed if the user selects CANCEL before it has ended. Also I think I used some GLOBAL variables in this.

Andy M-S
12-27-2001, 04:52 PM
That'll work OK, but it's probably still a good idea to back up any .ini file that you're going to modify. After all, your user may want to change things back some day!