A+ Certification / Beginners

Registry

Windows uses its Registry to record settings for applications and for the operating system.

When people first started writing applications for Microsoft-driven computers, they usually needed to record a series of per-use or per-computer settings. In most cases, they wrote these settings to a file stored on that computer. This system worked fine most of the time, but the people who needed to manage those computers and applications found that some of these configuration files were binary files and some were text files, and occasionally they would get corrupted and be unusable. To solve some of this confusion, Microsoft came up with a file standard that appeared when Windows was introduced to the world.

The new solution was the .ini ("innie") file, a text file that uses sections, settings, and values stored in a standardized format. Because the data is written and can be retrieved using a standard format, the operating system can use standard procedures to store and retrieve the data rather than relying on each application developer to write their own procedures. Listing below shows a portion of a sample .ini file.

Listing: A Sample .ini File
[Options]
WordSel=0
Units=0
Maximized=0
FrameRect=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
PageMargin=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
DefaultFormat=5
[Text]
Layout2=CAAAAAAAAAEAAAAAAADAAAAAAAAA
LayoutAux2=CAAAAAAAAAEAAAAAAADAAAAAAAAA
Wrap=0
BarState0=0
BarState1=0
[RTF]
Layout2=CAAAAAAAAAEAAAAAAADAAAAAAAAA
LayoutAux2=CAAAAAAAAAEAAAAAAADAAAAAAAAA
Wrap=0
BarState0=0
BarState1=0

You should note that the section names are enclosed in square brackets.

Originally, these .ini files could be stored in the application directory, in the Windows directory, or anywhere on the file system path, and this location variability often led to problems, such as multiple, conflicting .ini files and uncertainty as to which file was in use.

With the release of Windows 95 and Windows NT, Microsoft programmers developed a new way to deal with this issue - they created a single location in which to store all configuration information for a computer. This was called the Registry. Like .ini files, the Registry uses a standard format. The Registry breaks settings down into two basic categories: settings for computers and settings for users. Computer settings are stored in a section named HKEY_ LOCAL_MACHINE, while user settings are stored in HKEY_CURRENT_USER. Application developers are encouraged to use this new location to store settings for their applications and have even been given a special software key to store their settings. It is up to the software developer to decide whether settings are user- or computer-based and to manage the settings appropriately.

Even though Microsoft provided the Registry as a location to store program settings, not all programmers use it for their programs, and some still use .ini files. You should expect to encounter some programs that are still using .ini files.

Remember that Registry stores all settings in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER, depending on whether the setting is related to the computer or the user.

[Previous] [Contents] [Next]