[Lazarus] DOS charset to UTF-8

Graeme Geldenhuys graemeg.lists at gmail.com
Mon Oct 19 09:55:17 CEST 2009


Hi,

I just faced the problem described at
http://www.lazarus.freepascal.org/index.php?topic=5103.0

My application uses TIniPropStorage to store settings.
If it is launched from read-only media or with limited filesystem access
rights, it crashes when trying to save settings. There seem to be no
way to catch the exception other than via application exception handler.

I'd like to avoid workarounds and find an actual solution for this
problem. So far, I see the following ways to resolve it:

1. To add a property to control PropertyStorage activity and disable
the storage if configuration file is read-only. At first glance
TCustomPropertyStorage.Active seems to be the property I need, but it
does not help to prevent saving settings. Is it by design?

2. To add a parameter to OnSavingProperties event that would help to
abort saving settings. In this case event handler would look like this:

  procedure IniPropStorageSavingProperties(Sender: TObject; 
    var CanSave: Boolean);
  begin
    if FileIsReadOnlyUTF8(IniPropStorage.IniFileName) then 
     CanSave := False;
  end

3. To add an event that is called if saving settings failed. In this
case I can get reed of error message by assigning an empty event
handler to such event.

If there is a preferable way of handling exceptions raised by
PropertyStorage I'll appreciate if someone let me know about them.




More information about the Lazarus mailing list