[Tutor] File like object for Windows registry

Alan Gauld alan.gauld at freenet.co.uk
Thu Aug 3 23:37:33 CEST 2006

> My app should run on debian and windows platforms.

Hard lines :-(

> For storing the configuration data, I use the ConfigParser module.
> What I find difficult is to determine a place for my configuration 
> file.

Config parser basically produces an .in file.
The rules that Windows uses to locate .ini files vary
according to Windows version. If you can assume you
only have to deal with Win2K and XP then things are
a bit easier since there is a recommended location
and indeed users have the concept of a home directory
- even the $HOME environment variable works.

However traditionally ini files were stored in one of
1) the Windows directory (%WINDIR%) or
2) the application home directory.
3) The C:\ root directory - but this is now strongly

If you want to have application level ini files as well as
per user configurations those are still the preferred
locations for the global files.

Between Windows 95 and Windows 2000 the Registry
was being pushed as the best place for config data
but as Registry performance and corruption problems
increase .ini files are coming back into favour.

To summarise. If you want to just have a per user
config file just store it in the users data folder. If you
also have a global ini file then I recommend putting
it in the app install folder. If the app is cross platform
I'd advise keeping well clear of the registry, but if
you must use it I'd favour using the WSH objects
rather than the Win32 API calls to access the
Registry - although it does add another dependency
to the app.


Alan G. 

More information about the Tutor mailing list