CIniFile: Difference between revisions

no edit summary
m (tweak)
No edit summary
Line 31: Line 31:
Here only a single section - [Workspace] - is defined, however the fact that an INI file can have have as many sections as it needs means that you can use this very file to set up options for how you want your program to behave.
Here only a single section - [Workspace] - is defined, however the fact that an INI file can have have as many sections as it needs means that you can use this very file to set up options for how you want your program to behave.


Note that section names (the ones in the square brackets), key names ("Home", "AppSrcPath", etc.) and key values can all contain spaces (although for my own part I prefer not to use those and depend on [[camelCase]] to supply readability).
Note that section names (the ones in the square brackets), key names ("Home", "AppSrcPath", etc.) and key values can all contain spaces (although for my own part I prefer not to use those and depend on [http://en.wikipedia.org/wiki/Camelcase camelCase] to supply readability).


The advantage of the INI file approach is that it can make programs configurable for different environments or uses without them having to be recompiled with different settings each time: the program can be made with a set of default values which can then be overridden at run-time by the settings in an INI file.  It has the advantage over Registry settings, which perform very much the same function, in that you don't need any special rights on the machine to set it up and make changes to it: you are just working with text files, so security policy issues about who has rights to the [[Windows Registry]], or who can run RegEdit or RegEdit32 do not apply - if you can run Notepad and modify files you can configure your application.
The advantage of the INI file approach is that it can make programs configurable for different environments or uses without them having to be recompiled with different settings each time: the program can be made with a set of default values which can then be overridden at run-time by the settings in an INI file.  It has the advantage over Registry settings, which perform very much the same function, in that you don't need any special rights on the machine to set it up and make changes to it: you are just working with text files, so security policy issues about who has rights to the [http://en.wikipedia.org/wiki/Windows_Registry Windows Registry], or who can run RegEdit or RegEdit32 do not apply - if you can run Notepad and modify files you can configure your application.


Here is an example where an additional section allowing the configuration of a database location and login has been added:
Here is an example where an additional section allowing the configuration of a database location and login has been added:
Anonymous user