TIniPropStorage - Serious Limitation, Bug, or Ignorance lazarus / 7-LCL ---------------------------------------------------------------------- WayneSherman · 2008-03-11 17:10 I am using a TIniPropStorage on my main form to store some program settings.  In general, it works great.  But, the program runs from a directory that is read-only for some users, and it throws an exception when they try to close (cannot write ini file...). I thought that this would be an easy fix, but I can't find a simple way of shutting off/preventing the "save" function.  I tried this: Code: [Select] type   TIniPropStorageCracker = class(TIniPropStorage); procedure TfrmMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); begin   if FileExists(TIniPropStorageCracker(IniPropStorage).GetIniFileName) then begin     IniPropStorage.Active := False;   end; end; Setting "Active" to false, does NOT prevent saving to the ini file.  I looked through the source, and cannot find a simple way to fix this. Am I missing something?  Any help would be appreciated. Thanks, Wayne ---------------------------------------------------------------------- Leledumbo · 2008-03-12 11:37 Not sure if it works: Code: [Select] procedure IniPropStorage.OnSaveProperties (Sender: TObject); begin   Exit; end; or Code: [Select] procedure IniPropStorage.OnSavingProperties (Sender: TObject); begin   Exit; end; ---------------------------------------------------------------------- WayneSherman · 2008-03-14 19:02 I checked the source code, and that won't work.  A more typical way might be: Code: [Select] procedure IniPropStorage.OnSavingProperties (Sender: TObject); begin   raise EAbort.Create('aborting ini save'); end; But that won't work since there is no exception handling in place.  The place to catch an EAbort exception catch might be here: propertystorage.pas original code: Code: [Select] procedure TCustomPropertyStorage.Save; begin   if FRestored or not Active then     begin     StorageNeeded(False);     Try       if Assigned(FOnSavingProperties) then         FOnSavingProperties(Self);       SaveProperties;       FStoredValues.SaveValues;       NotifyLinks(poSave);       if Assigned(FOnSaveProperties) then         FOnSaveProperties(Self);       FSaved := True;     Finally       FreeStorage;     end;     end; end; propertystorage.pas modified code: Code: [Select] procedure TCustomPropertyStorage.Save; begin   try     if FRestored or not Active then       begin       StorageNeeded(False);       Try         if Assigned(FOnSavingProperties) then           FOnSavingProperties(Self);         SaveProperties;         FStoredValues.SaveValues;         NotifyLinks(poSave);         if Assigned(FOnSaveProperties) then           FOnSaveProperties(Self);         FSaved := True;       Finally         FreeStorage;       end;       end;   except     on EAbort do EXIT;     raise;   end; end;