Home Up Best Cleaner About Us Site Map

                  

 

Additional Registry Education

Most people do not want too get too involved in learning the registry system and about the repair of Windows registry problems. Instead they just want the computer to run at a higher performance level. One might say, "I don't need to know how electricity works in order to flick the switch to turn on the lights."

This section goes into additional details about the Windows registry for people who want to know more. If you are overwhelmed just by reading the information below, just choose a registry cleaner from the best registry cleaner section and fix the issue quickly and easily.

All of the information below is quoted directly from Microsoft and can be found at available at http://msdn2.microsoft.com/en-us/library/ms724871.aspx if you would like the full access to registry information.

What is the Windows Registry?

The registry is a system-defined database in which applications and system components store and retrieve configuration data. The data stored in the registry varies according to the version of Microsoft Windows. Applications use the registry API to retrieve, modify, or delete registry data.”

You should not edit registry data that does not belong to your application unless it is absolutely necessary. If there is an error in the registry, your system may not function properly.

How is the Registry Structured?

The registry stores data in a tree format. Each node in the tree is called a key. Each key can contain both subkeys and data entries called values. Sometimes, the presence of a key is all the data that an application requires; other times, an application opens a key and uses the values associated with the key. A key can have any number of values, and the values can be in any form. For more information, see Registry Value Types and Registry Element Size Limits.

Each key has a name consisting of one or more printable characters. Key names are not case sensitive. Key names cannot include a backslash (\), but any other printable or unprintable character can be used. The name of each sub-key is unique with respect to the key that is immediately above it in the hierarchy. Key names are not localized into other languages, although values may be.

The following figure is an example registry key structure as displayed by the Registry Editor.

 Below is a Screen Print of the Windows Registry Editor

Windows Registry Editor Interface

Each of the trees under My Computer is a key. The HKEY_LOCAL_MACHINE key has the following subkeys: HARDWARE, SAM, SECURITY, SOFTWARE, and SYSTEM. Each value consists of a value name and its associated data, if any. MaxObjectNumber and VgaCompatible are values under the DEVICEMAP\VIDEO subkey that contain data.

A registry tree can be 512 levels deep. You can create up to 32 levels at a time through a single registry API call.”

What are the Categories of Data in the Registry?

 “Before putting data into the registry, an application should divide the data into two categories: computer-specific data and user-specific data. By making this distinction, an application can support multiple users, and yet locate user-specific data over a network and use that data in different locations, allowing location-independent user profile data. (A user profile is a set of configuration data saved for every user.)

When the application is installed, it should record the computer-specific data under the HKEY_LOCAL_MACHINE key. In particular, it should create keys for the company name, product name, and version number, as shown in the following example:

HKEY_LOCAL_MACHINE\Software\MyCompany\MyProduct\1.0

If the application supports COM, it should record that data under HKEY_LOCAL_MACHINE\Software\Classes.

An application should record user-specific data under the HKEY_CURRENT_USER key, as shown in the following example:

HKEY_CURRENT_USER\Software\MyCompany\MyProduct\1.0”

Registry Value Types:

A registry value can store data in various formats. When you store data under a registry value, for instance by calling the RegSetValueEx function, you can specify one of the following values to indicate the type of data being stored. When you retrieve a registry value, functions such as RegQueryValueEx use these values to indicate the type of data retrieved.

The following registry value types are defined in Winnt.h.

Value

Type

REG_BINARY

Binary data in any form.

REG_DWORD

A 32-bit number.

REG_DWORD_LITTLE_ENDIAN

A 32-bit number in little-endian format.

Windows is designed to run on little-endian computer architectures. Therefore, this value is defined as REG_DWORD in the Windows header files.

REG_DWORD_BIG_ENDIAN

A 32-bit number in big-endian format.

Some UNIX systems support big-endian architectures.

REG_EXPAND_SZ

A null-terminated string that contains unexpanded references to environment variables (for example, "%PATH%"). It will be a Unicode or ANSI string depending on whether you use the Unicode or ANSI functions. To expand the environment variable references, use the ExpandEnvironmentStrings function.

REG_LINK

A null-terminated Unicode string that contains the target path of a symbolic link that was created by calling the RegCreateKeyEx function with REG_OPTION_CREATE_LINK.

REG_MULTI_SZ

A sequence of null-terminated strings, terminated by an empty string (\0).

The following is an example:

String1\0String2\0String3\0LastString\0\0

The first \0 terminates the first string, the second to the last \0 terminates the last string, and the final \0 terminates the sequence. Note that the final terminator must be factored into the length of the string.

REG_NONE

No defined value type.

REG_QWORD

A 64-bit number.

REG_QWORD_LITTLE_ENDIAN

A 64-bit number in little-endian format.

Windows is designed to run on little-endian computer architectures. Therefore, this value is defined as REG_QWORD in the Windows header files.

REG_SZ

A null-terminated string. This will be either a Unicode or an ANSI string, depending on whether you use the Unicode or ANSI functions.

String Values:

If data has the REG_SZ, REG_MULTI_SZ, or REG_EXPAND_SZ type, the string may not have been stored with the proper terminating null characters. Therefore, when reading a string from the registry, you must ensure that the string is properly terminated before using it; otherwise, it may overwrite a buffer. (Note that REG_MULTI_SZ strings should have two terminating null characters.)

When writing a string to the registry, you must specify the length of the string, including the terminating null character (\0). A common error is to use the strlen function to determine the length of the string, but to forget that strlen returns only the number of characters in the string, not including the terminating null. Therefore, the length of the string should be calculated as follows: strlen( string ) + 1

A REG_MULTI_SZ string ends with a string of length 0. Therefore, it is not possible to include a zero-length string in the sequence. An empty sequence would be defined as follows: \0.

The following example walks a REG_MULTI_SZ string.

Copy Code

#include <windows.h> #include <tchar.h> #include <stdio.h> void SampleSzz(PTSTR pszz) { _tprintf(_TEXT("\tBegin multi-sz string\n")); while (*pszz) { _tprintf(_TEXT("\t\t%s\n"), pszz); pszz = pszz + _tcslen(pszz) + 1; } _tprintf(_TEXT("\tEnd multi-sz\n")); } int __cdecl main(int argc, char **argv) { // Because the compiler adds a \0 at the end of quoted strings, // there are two \0 terminators at the end. _tprintf(_TEXT("Conventional multi-sz string:\n")); SampleSzz(_TEXT("String1\0String2\0String3\0LastString\0")); _tprintf(_TEXT("\nTest case with no strings:\n")); SampleSzz(_TEXT("")); return 0; }

Byte Formats:

In little-endian format, a multi-byte value is stored in memory from the lowest byte (the "little end") to the highest byte. For example, the value 0x12345678 is stored as (0x78 0x56 0x34 0x12) in little-endian format.

In big-endian format, a multi-byte value is stored in memory from the highest byte (the "big end") to the lowest byte. For example, the value 0x12345678 is stored as (0x12 0x34 0x56 0x78) in big-endian format.

Registry Element Size Limits:

The following table identifies the size limits for the various registry elements.

Registry Element

Size Limit

Key name

255 characters

Value name

16,383 characters

Windows 2000:  260 ANSI characters or 16,383 Unicode characters.

Windows Me/98/95:  255 characters

Value

Available memory (latest format)

1MB (standard format)

Windows Me/98/95:  16,300 bytes.

Windows 95:  There is a 64K limit for the total size of all values of a key.

Tree

A registry tree can be 512 levels deep. You can create up to 32 levels at a time through a single registry API call.

Long values (more than 2,048 bytes) should be stored as files with the file names stored in the registry. This helps the registry perform efficiently.

Registry Storage Space:

Although there are few technical limits to the type and size of data an application can store in the registry, certain practical guidelines exist to promote system efficiency. An application should store configuration and initialization data in the registry, and store other kinds of data elsewhere.

Generally, data consisting of more than one or two kilobytes (K) should be stored as a file and referred to by using a key in the registry rather than being stored as a value. Instead of duplicating large pieces of data in the registry, an application should save the data as a file and refer to the file. Executable binary code should never be stored in the registry.

A value entry uses much less registry space than a key. To save space, an application should group similar data together as a structure and store the structure as a value rather than storing each of the structure members as a separate key. (Storing the data in binary form allows an application to store data in one value that would otherwise be made up of several incompatible types.)

Views of the registry files are mapped in the computer cache address space. Therefore, regardless of the size of the registry data, it is not charged more than 4 megabytes (MB). There are no longer any explicit limits on the total amount of space that may be consumed by hives in paged pool memory, and in disk space. The size of the system hive is limited only by physical memory.

Windows 2000 and Windows NT:

Registry data is stored in the paged pool, an area of physical memory used for system data that can be written to disk when not in use. The RegistrySizeLimit value establishes the maximum amount of paged pool that can be consumed by registry data from all applications. This value is located in the following registry key:

HKEY_LOCAL_MACHINE
     System
          CurrentControlSet
               Control

By default, the registry size limit is 25 percent of the paged pool. (The default size of the paged pool is 32 MB, so this is 8 MB.) The system ensures that the minimum value of RegistrySizeLimit is 4 MB and the maximum is approximately 80 percent of the PagedPoolSize value. If the value of this entry is greater than 80 percent of the size of the paged pool, the system sets the maximum size of the registry to 80 percent of the size of the paged pool. This prevents the registry from consuming space needed by processes. Note that setting this value does not allocate space in the paged pool, nor does it assure that the space will be available if needed.

The paged pool size is determined by the PagedPoolSize value in the following registry key:

HKEY_LOCAL_MACHINE
     System
          CurrentControlSet
               Control
                    SessionManager
                         MemoryManagement

For more information on RegistrySizeLimit and PagedPoolSize, refer to the registry help file, Regentry.chm, in the Windows Resource Kit.

For an example of how to determine the current and maximum sizes of the registry, see Determining the Registry Size.

Windows 2000:  The maximum paged pool is approximately 300,470 MB so the registry size limit is 240-376 MB. However, if the /3GB switch is used, the maximum paged pool size is 192 MB, so the registry can be a maximum of 153.6 MB.

Windows NT 4.0:  The maximum paged pool size is 192 MB, so the registry size limit is 153.6 MB.

Windows NT 3.51 and earlier:  The maximum paged pool is 128 MB, so the registry size limit is 102 MB.

Predefined Keys:

An application must open a key before it can add data to the registry. To open a key, an application must supply a handle to another key in the registry that is already open. The system defines predefined keys that are always open. Predefined keys help an application navigate in the registry and make it possible to develop tools that allow a system administrator to manipulate categories of data. Applications that add data to the registry should always work within the framework of predefined keys, so administrative tools can find and use the new data.

An application can use handles to these keys as entry points to the registry. These handles are valid for all implementations of the registry, although the use of the handles may vary from platform to platform. In addition, other predefined handles have been defined for specific platforms. The following are handles to the predefined keys.

Handle

Description

HKEY_CLASSES_ROOT

Registry entries subordinate to this key define types (or classes) of documents and the properties associated with those types. Shell and COM applications use the information stored under this key. For more information, see HKEY_CLASSES_ROOT Key

This key also provides backward compatibility with the Windows 3.1 registration database by storing information for DDE and OLE support. File viewers and user interface extensions store their OLE class identifiers in HKEY_CLASSES_ROOT, and in-process servers are registered in this key.

This handle should not be used in a service or an application that impersonates different users.

HKEY_CURRENT_CONFIG

Contains information about the current hardware profile of the local computer system. The information under HKEY_CURRENT_CONFIG describes only the differences between the current hardware configuration and the standard configuration. Information about the standard hardware configuration is stored under the Software and System keys of HKEY_LOCAL_MACHINE.

HKEY_CURRENT_CONFIG is an alias for HKEY_LOCAL_MACHINE\System\CurrentControlSet\Hardware Profiles\Current.

Windows NT 3.51 and earlier:  This key does not exist.

HKEY_CURRENT_USER

Registry entries subordinate to this key define the preferences of the current user. These preferences include the settings of environment variables, data about program groups, colors, printers, network connections, and application preferences. This key makes it easier to establish the current user's settings; the key maps to the current user's branch in HKEY_USERS. In HKEY_CURRENT_USER, software vendors store the current user-specific preferences to be used within their applications. Microsoft, for example, creates the HKEY_CURRENT_USER\Software\Microsoft key for its applications to use, with each application creating its own subkey under the Microsoft key.

The mapping between HKEY_CURRENT_USER and HKEY_USERS is per process and is established the first time the process references HKEY_CURRENT_USER. The mapping is based on the security context of the first thread to reference HKEY_CURRENT_USER. If this security context does not have a registry hive loaded in HKEY_USERS, the mapping is established with HKEY_USERS\.Default. After this mapping is established it persists, even if the security context of the thread changes.

This handle should not be used in a service or an application that impersonates different users. Instead, call the RegOpenCurrentUser function.

HKEY_DYN_DATA

Windows Me/98/95:  Registry entries subordinate to this key allow you to collect performance data.

HKEY_LOCAL_MACHINE

Registry entries subordinate to this key define the physical state of the computer, including data about the bus type, system memory, and installed hardware and software. It contains subkeys that hold current configuration data, including Plug and Play information (the Enum branch, which includes a complete list of all hardware that has ever been on the system), network logon preferences, network security information, software-related information (such as server names and the location of the server), and other system information.

HKEY_PERFORMANCE_DATA

Registry entries subordinate to this key allow you to access performance data. The data is not actually stored in the registry; the registry functions cause the system to collect the data from its source.

Windows Me/98/95:  This key is not supported.

HKEY_PERFORMANCE_NLSTEXT

Registry entries subordinate to this key reference the text strings that describe counters in the local language of the area in which the computer system is running. These entries are not available to Regedit.exe and Regedt32.exe.

Windows 2000/NT and Windows Me/98/95:  This key is not supported.

HKEY_PERFORMANCE_TEXT

Registry entries subordinate to this key reference the text strings that describe counters in US English. These entries are not available to Regedit.exe and Regedt32.exe.

Windows 2000/NT and Windows Me/98/95:  This key is not supported.

HKEY_USERS

Registry entries subordinate to this key define the default user configuration for new users on the local computer and the user configuration for the current user.

The RegOverridePredefKey function enables you to map a predefined registry key to a specified key in the registry. For instance, a software installation program could remap a predefined key before installing a DLL component. This enables the installation program to easily examine the information that the DLL's installation procedure writes to the predefined key.

The RegDisablePredefinedCache and RegDisablePredefinedCacheEx functions disable handle caching for predefined registry handles. Services that use impersonation should call RegDisablePredefinedCacheEx before using predefined registry handles.

The predefined handles are not thread safe. Closing a predefined handle in one thread affects any other threads that are using the handle.

Registry Files:

Applications can save part of the registry in a file and then load the contents of the file back into the registry. A registry file is useful when a large amount of data is being manipulated, when many entries are being made in the registry, or when the data is transitory and must be loaded and then unloaded again. Applications that back up and restore parts of the registry are likely to use registry files.

To save a key and its subkeys and values to a registry file, an application can call the RegSaveKey or RegSaveKeyEx function.

RegSaveKey and RegSaveKeyEx create the file with the archive attribute. The file is created in the current directory of the process for a local key, and in the %systemroot%\system32 directory for a remote key.

Windows Me/98/95:  The file is created in the Windows directory with the archive, hidden, read-only, and system attributes.

Registry files have the following two formats: standard and latest. The standard format is the only format supported by Windows 2000 and Windows NT. It is also supported by later versions of Windows for backward compatibility. RegSaveKey creates files in the standard format.

The latest format is supported starting with Windows XP. Registry files that are created in this format cannot be loaded on Windows 2000 and Windows NT. RegSaveKeyEx can save registry files in either format by specifying either REG_STANDARD_FORMAT or REG_LATEST_FORMAT. Therefore, it can be used to convert registry files that use the standard format to the latest format.

To write the registry file back to the registry, an application can use the RegLoadKey, RegReplaceKey, or RegRestoreKey functions as follows.

  • RegLoadKey loads registry data from a specified file into a specified subkey under HKEY_USERS or HKEY_LOCAL_MACHINE on the calling application's computer or on a remote computer. The function creates the specified subkey if it does not already exist. After calling this function, an application can use the RegUnLoadKey function to restore the registry to its previous state.
  • RegReplaceKey replaces a key and all its subkeys and values in the registry with the data contained in a specified file. The new data takes effect the next time the system is started.
  • RegRestoreKey loads registry data from a specified file into a specified key on the calling application's computer or on a remote computer. This function replaces the subkeys and values below the specified key with the subkeys and values that follow the top-level key in the file.

The RegConnectRegistry function establishes a connection to a predefined registry handle on another computer. An application uses this function primarily to access information from a remote registry on other machines in a network environment, which you can also do by using the Registry Editor. You might want to access a remote registry to back up a registry or regulate network access to it. Note that you must have appropriate permissions to access a remote registry using this function.

Again, you can see how complicated the Windows Registry can be. With just one mistake you could hurt the performance and even the complete operations of your computer. The easiest way to fix registry issues is to set pride aside and forget the whole, "I can fix it" attitude when software programs are so inexpensive and can do the fixing for you in a safe way. Just make sure that the software you are using has a file backup option before downloading and paying for the full version. Visit the  best registry cleaner section for the top registry optimizer and registry registry fix solutions.

If you still want more information about Windows registry, visit the Microsoft links below: WARNING - You will be guided off this site by clicking on the following links.

Windows registry information for advanced users (below)

http://support.microsoft.com/kb/256986

How to back up and restore the registry in Windows XP and Windows Vista (below)

http://support.microsoft.com/kb/322756

Windows 2000 Registry Repair Utility (below - download link)

http://support.microsoft.com/kb/183887http://www.microsoft.com/downloads/details.aspx?FamilyID=56D3C201-2C68-4DE8-9229-CA494362419C&displaylang=en

How to back up, edit, and restore the registry in Windows 2000 (below)

http://support.microsoft.com/kb/322755


Return to Registry Articles Page

Index Page

About Us

Site Map

 

 

 

 

 

 

                  

 

Copyright 2008 registry-repair-source.com.  All Rights Reserved

Home   About Us