Lau said:
Using INI files to store value is obsolute. Consider storing values on
HKCU/HKLM registry keys instead.
Why?
Microsoft says that you should use a config file (ie a text file in the
application's folder) in preference to a registry key. Guess what an ini
file is? It is a text file in the application's folder!
There are distinct reasons *not* to use the registry. The most important
is that it kills xcopy deployment (how do you extract the values in the
registry from one machine and put them into the registry of another with
xcopy?). If you want xcopy deployment *do not* use the registry. Also
the registry tends to get bloated. If an application does not clean up
after itself it will leave values in the registry after it is
uninstalled and this bloating will eventually have an effect on the
performance of windows.
There *are* reasons why you should use the registry: it is a multiuser
database, so multiple threads can access the registry at the same time.
This is (usually) not the case with a file because a thread will lock
the file and prevent access to other threads. The registry is also
accessible via RPC, so a remote machine can change it. If you want to
have these enefits then you should use the registry. Otherwise, the
xcopy argument means that you should not use it.
That then leaves the question of whether you should use a config file
(XML) or an ini file. XML files are structured and so you can put richer
information in them. Personally I would not use the configuration file
API because in v1.1 this API only give you read-only access. If you want
to write data then use the XML serialization classes (XmlSerializer).
The xsd.exe tool is emmensly useful in generating code to do this.
Richard