Note: You will see the new WebTechGeek web page format with -
older WTG web page format. I hope you like the new!
Windows
Registry Guide!
More software downloadsWindows Registry Guide:
by Raymond Garcia
WebTechGeek.com
What Is Windows Registry?
The registry is a simple, hierarchical database
of information that Windows operating systems (and some
applications) use to define the configuration of the system.
Originally, in the early, simple days of Windows (16-bit
Windows versions especially), the same information that
is now stored in the registry was stored in text files.
Though these text files were simple, theirorganization
made access to the information they contained too slow
to keep up with increasingly speedy technology.
Many applications use the registry the
same way, though some applications are now movingto separate
storage locations for their data—a technique that
allows the applications to easilyback up and restore their
configuration data.
The development of the registry, like Windows,
has been evolutionary. The registry was preceded by a
pair of flat-text files, called win.ini and system.ini.
While the performance with these files left something
to be desired, they formed the basis for today's registry.
In fact, these two files live on today
in Windows XP, though they are virtually unchanged from
Windows NT version 4. The first registry to appear in
Windows was created to solve anumber of problems: poor
performance (retrieving information from the original
flat-text .inifiles was cumbersome), size limitations
(the .ini files could be only so large), and maintenance
problems (the .ini files were organizationally impaired!).
Today, the Windows XP system .ini files
contain only a few entries used by a few applications.
(Most are legacy 16-bit applications, though a few new
programs are also placing some items in the win.ini file,
too!)
These system .ini files are of no importance
to us, and we may safely ignore them. ForWindows XP, it's
the registry that is most important to the system, because
it contains the heart and soul of Windows XP. Without
the registry, Windows XP would be nothing morethan a collection
of programs, unable to perform even the basic tasks that
we expect from an operating system. Every bit of configuration
information that Windows XP has is crammed into the registry.
Information about the system's hardware, preferences,
security, and users—everything that can be set is
set in there.
However, times are a-changing. Microsoft
now realizes that if every application storesapplication-specific
information in the system registry, then the system registry
can grow toan enormous size. That isn't quite what Microsoft
had in mind when they created the registrystructure. Microsoft's
policy now states that applications may (and should) use
standalone .ini files as needed.
Some advantages to using application-specific
.ini files include these:
• Individual applications sometimes
need to be restored from backup. With an application-specific
.ini file, it is not necessary to back up and restore
the entireregistry to reinstall any single application.
(This eliminates the attendant problem ofrestoring one
part of the registry only to lose another part during
the restoration!)
• The system registry has a practical
limited size. Granted, the size is large, but someapplications
have lately been adding substantial content to the registry
without regardto the fact (sad as it is) that the registry
is a shared resource that everyone, includingthe system,
must use! Once the registry gets too large, some registry
operations maytake an excessive amount of time.
Note Microsoft limits the size of any object
that is stored in a registry data key to 1MB. This limit
is basically only meaningful for REG_BINARY objects, because
strings and such are unlikely to become this large. If
you must store more than 1MB in a registry object,then
store the information in a file and store a pointer to
the file in the registry. Withoutthis limitation, the
registry could easily grow to be the largest file on your
system.
For Windows before Windows XP:
Windows 2000 and earlier versions set restrictions
on registry size. If you approach your registry limit,
you'll get a message stating that you are low on registry
quota. This indicates that the registry has grown too
large for the current size allocation. Unless you change
it, the registry size is set to 25 percent of the paged
pool size; for most computers, the paged pool size is
approximately equal to the amount of installed RAM, up
to a maximum of 192MB.
The registry can be set to 80 percent of
the paged pool size (80 percent of 192MB is justunder
154MB, though good sense says to round down to 150MB).
Earlier versions of Windows adjust the registry
size based on the currently installed RAM. Several registry
entries affect registry size, though most users will find
that the defaults are acceptable for their use. To create
a very large registry, ensure that the amount of RAM installed
is sufficient and set the RegistrySizeLimit and PagedPoolSize
entries.
Organization
The registry is organized into five major
sections. These sections are called hives, which are analogous
to root directories on your hard drive. Each hive, by
definition, has its own storage location (a file) and
log file. If necessary, a given hive can be restored without
affecting the other hives in the registry. Inside a hive
you find both keys (and subkeys, analogous to directories
and subdirectories on your hard disk) and values. The
term value (or data value, as it is sometimes called)
refers to the information, or data, assigned to a key,
making the key analogous to a file on your hard drive
as well.
A key or subkey may have zero, one, or more
value entries, a default value, and from zero to many
subkeys. Each value entry has a name, data type, and a
value:
• The entry's name is stored as a
Unicode character string.
• The entry's type is stored as an integer index.
The type is returned to the querying application, which
must then map this type to the type that the application
knows.
• The entry's value is stored as necessary to allow
efficient retrieval of the data when needed.
Both the Windows XP operating system and
applications store data in the Windows XP registry. This
is both good and bad. It is good because the registry
makes an efficient, common storage location. Here's the
bad part: as I mentioned earlier, as more and more applications
and systems store information in the registry, it grows
larger, and larger, and larger.
It is most unusual for the registry to get
smaller—I'm unaware of any application that does
a really complete job of cleaning up all of its own registry
entries when the application is uninstalled. Many applications
leave tons of stuff in the registry when they are uninstalled,
and not many applications clean up unused entries as a
routine process. The end result is that the registry will
grow, like Jack's magic beanstalk, as time goes on.
Note From time to time in this book I'll refer to hives,
keys, subkeys, and values using thegeneric term object.
When the term object is used, assume that the item could
be any valid item in the registry!
Hives and Their Aliases:
There are five main, or top level, hives
in the Windows XP registry, and accepted
abbreviations _for each:
• HKEY_CLASSES_ROOT, a.k.a. HKCR
• HKEY_CURRENT_USER, a.k.a. HKCU
• HKEY_LOCAL_MACHINE, a.k.a. HKLM
• HKEY_USERS, a.k.a. HKU
• HKEY_CURRENT_CONFIG, a.k.a. HKCC
Note The Windows 98 and Windows Me (Millennium
Edition) HKEY_DYN_DATA hive, which has no abbreviation,
does not exist in Windows XP, though Microsoft had.
originally intended to include information
about Plug and Play in this hive. So where is PnP data
saved if the HKEY_DYN_DATA hive is gone? Windows XP supports
PnP, and Microsoft decided to integrate PnP data with
the main registry rather than use a separate hive.
Each hive begins with HKEY_. HKEY is an
abbreviation for "hive key," though thesignificance
of this is not terribly important in understanding the
registry. The H also signifies that the name is a "handle"
for a program to interface with the registry. These handles
are defined in the file winreg.h, included with the Windows
XP SDK (Software Development Kit).