Recent

Author Topic: Storing application settings  (Read 5436 times)

kapibara

  • Hero Member
  • *****
  • Posts: 610
Storing application settings
« on: October 11, 2013, 10:22:26 pm »
I'm writing a program that will run on both Linux and Windows. Windows has the registry but that wont work with Linux.

I want one type of settings storage that works on both systems. Is this possible?





Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Storing application settings
« Reply #1 on: October 11, 2013, 10:29:40 pm »
On the Misc page of the Component Palette there are two components that you may want to explore:
TIniPropStorage
TXMLPropStorage
The example for mru storage may also give you some pointers. It uses TIniFile:
...\lazarus\components\mrumenu\mrumanager.pp
« Last Edit: October 11, 2013, 10:37:11 pm by howardpc »

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: Storing application settings
« Reply #2 on: October 11, 2013, 11:31:14 pm »
Thanks!

On the Misc page of the Component Palette there are two components that you may want to explore:
TIniPropStorage
TXMLPropStorage
The example for mru storage may also give you some pointers. It uses TIniFile:
...\lazarus\components\mrumenu\mrumanager.pp
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

vladvons

  • Jr. Member
  • **
  • Posts: 65
Re: Storing application settings
« Reply #3 on: October 11, 2013, 11:51:19 pm »
look also at Component Palette->System->TXMLConfig
http://wiki.freepascal.org/xmlconf
Windows 7, Ubuntu 12.04, Lazarus 1.2.2, FPC 2.6.4, PostgreSQL 9.2

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Storing application settings
« Reply #4 on: October 12, 2013, 03:37:18 am »
I always use T*PropStorage (mostly TIniPropStorage because using XML as configuration makes it difficult to edit by hand) as they are the real RAD style of doing this. Very easy to use and easy to add custom values as well.

vladvons

  • Jr. Member
  • **
  • Posts: 65
Re: Storing application settings
« Reply #5 on: October 12, 2013, 07:54:37 am »
Is it possible to work with Stream instead of File in TPropStorage ?
I want to save/restore settings using database
Windows 7, Ubuntu 12.04, Lazarus 1.2.2, FPC 2.6.4, PostgreSQL 9.2

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Storing application settings
« Reply #6 on: October 12, 2013, 10:16:42 am »
Quote
Is it possible to work with Stream instead of File in TPropStorage ?
I guess not, after all they're concrete classes. Perhaps you can implement a db backend descendant for TFormPropertyStorage (base class for TIniPropStorage and TXMLPropStorage, say TDBPropStorage or something.

 

TinyPortal © 2005-2018