Store essential user settings that must move with the individual in the user’s profile

Store essential user settings that must move with the individual in the user’s profile

Benefits

Description

Users that have to use your application on multiple machines don't want to lose valuable time getting things the way they like and are accustomed to, each and every time they log in somewhere else! If a user takes the time to configure your application beyond the default settings, then your application should take the time to make sure those settings are available to the user wherever he or she may roam on the network.

Settings that your program uses on a per-user basis should be placed in HKEY_CURRENT_USER. For example, a mail client would store server name, user-id etc.

A good rule of thumb for registry usage is to not exceed 100k. If you have a lot of settings then consider only storing the mission critical ones. For example, while nice to have, your program will run just fine if Window sizes and positions don’t roam. But if you don’t roam the name of the mail server then you could have real problems!

If you have more than 100k of settings, use a settings file. If you don’t need your settings file to roam, put it in CSIDL_LOCAL_APPDATA. If you want to roam then put the settings file in CSIDL_APP_DATA.

Considerations

Try to decide what needs to roam. If you have lots of data, 100k or more, then just roam the important stuff.

Be aware of the tradeoffs involved with using settings files vs. using the registry.

When calculating size of combined settings, don’t include settings stored elsewhere like HKEY_LOCAL_MACHINE, HKEY_CURRNET_CONFIG or policy settings.

See Also

CSIDLs, Registry Functions, Registry Overview, SHGetFolderPath