Keys and Values
The registry contains two basic elements: keys and values. Registry keys are similar to folders—in addition to values, each key can contain subkeys, which may contain further subkeys, and so on. Keys are referenced with a syntax similar to Windows' path names, using backslashes to indicate levels of hierarchy. Each subkey has a mandatory name, which is a non-empty string that cannot contain any backslash, and whose letter case is insignificant.
The hierarchy of registry keys can only be accessed from a known root key handle (which is anonymous but whose effective value is a constant numeric handle) that is mapped to the content of a registry key preloaded by the kernel from a stored "hive", or to the content of a subkey within another root key, or mapped to a registered service or DLL that provides access to its contained subkeys and values.
E.g. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows refers to the subkey "Windows" of the subkey "Microsoft" of the subkey "Software" of the HKEY_LOCAL_MACHINE root key.
There are seven predefined root keys, traditionally named according to their constant handles defined in the Win32 API, or by synonymous abbreviations (depending on applications):
- HKEY_LOCAL_MACHINE or HKLM
- HKEY_CURRENT_CONFIG or HKCC (only in Windows 9x/Me and NT-based versions of Windows)
- HKEY_CLASSES_ROOT or HKCR
- HKEY_CURRENT_USER or HKCU
- HKEY_USERS or HKU
- HKEY_PERFORMANCE_DATA (only in NT-based versions of Windows, but invisible in the Windows Registry Editor)
- HKEY_DYN_DATA (only in Windows 9x/Me, and visible in the Windows Registry Editor)
Like other files and services in Windows, all registry keys may be restricted by access control lists (ACLs), depending on user privileges, or on security tokens acquired by applications, or on system security policies enforced by the system (these restrictions may be predefined by the system itself, and configured by local system administrators or by domain administrators). Different users, programs, services or remote systems may only see some parts of the hierarchy or distinct hierarchies from the same root keys.
Registry values are name/data pairs stored within keys. Registry values are referenced separately from registry keys. Each registry value stored in a registry key has a unique name whose letter case is not significant. The Windows API functions that query and manipulate registry values take value names separately from the key path and/or handle that identifies the parent key. Registry values may contain backslashes in their names, but doing so makes them difficult to distinguish from their key paths when using some legacy Windows Registry API functions (whose usage is deprecated in Win32).
The terminology is somewhat misleading, as each registry key is similar to an associative array, where standard terminology would refer to the name part of each registry value as a "key". The terms are a holdout from the 16-bit registry in Windows 3, in which registry keys could not contain arbitrary name/data pairs, but rather contained only one unnamed value (which had to be a string). In this sense, the entire registry was like a single associative array where the registry keys (in both the registry sense and dictionary sense) formed a hierarchy, and the registry values were all strings. When the 32-bit registry was created, so was the additional capability of creating multiple named values per key, and the meanings of the names were somewhat distorted. For compatibility with the previous behavior, each registry key may have a "default" value, whose name is the empty string.
Each value can store arbitrary data with variable length and encoding, but which is associated with a symbolic type (defined as a numeric constant) defining how to parse this data. The standard types are:
Type ID | Symbolic type name | Meaning and encoding of the data stored in the registry value |
---|---|---|
0 | REG_NONE | No type (the stored value, if any) |
1 | REG_SZ | A string value, normally stored and exposed in UTF-16LE (when using the Unicode version of Win32 API functions), usually terminated by a null character |
2 | REG_EXPAND_SZ | An "expandable" string value that can contain environment variables, normally stored and exposed in UTF-16LE, usually terminated by a null character |
3 | REG_BINARY | Binary data (any arbitrary data) |
4 | REG_DWORD / REG_DWORD_LITTLE_ENDIAN | A DWORD value, a 32-bit unsigned integer (numbers between 0 and 4,294,967,295 ) (little-endian) |
5 | REG_DWORD_BIG_ENDIAN | A DWORD value, a 32-bit unsigned integer (numbers between 0 and 4,294,967,295 ) (big-endian) |
6 | REG_LINK | A symbolic link (UNICODE) to another registry key, specifying a root key and the path to the target key |
7 | REG_MULTI_SZ | A multi-string value, which is an ordered list of non-empty strings, normally stored and exposed in UTF-16LE, each one terminated by a null character, the list being normally terminated by a second null character. |
8 | REG_RESOURCE_LIST | A resource list (used by the Plug-n-Play hardware enumeration and configuration) |
9 | REG_FULL_RESOURCE_DESCRIPTOR | A resource descriptor (used by the Plug-n-Play hardware enumeration and configuration) |
10 | REG_RESOURCE_REQUIREMENTS_LIST | A resource requirements list (used by the Plug-n-Play hardware enumeration and configuration) |
11 | REG_QWORD / REG_QWORD_LITTLE_ENDIAN | A QWORD value, a 64-bit integer (either big- or little-endian, or unspecified) (Introduced in Windows XP) |
Read more about this topic: Windows Registry, Structure
Famous quotes containing the words keys and, keys and/or values:
“without luggage or defenses,
giving up my car keys and my cash,
keeping only a pack of Salem cigarettes
the way a child holds on to a toy.
I signed myself in where a stranger
puts the inked-in Xs”
—Anne Sexton (19281974)
“McCoy: That sharks been following us ever since the surgeon died, waiting for the burial. Couldnt I have a musket to shoot it, sir?
Fletcher Christian: Take the deck, McCoy. Ill get the keys to the arms chest.
McCoy: Get two muskets, sir. Id like to shoot that shark on board.”
—Talbot Jennings (18961985)
“Our first line of defense in raising children with values is modeling good behavior ourselves. This is critical. How will our kids learn tolerance for others if our hearts are filled with hate? Learn compassion if we are indifferent? Perceive academics as important if soccer practice is a higher priority than homework?”
—Fred G. Gosman (20th century)