Wednesday, February 18, 2009

Using Registry Keys and Values

Each hive is at the top of the hierarchy, and underneath each hive are keys, which can in turn contain subkeys, and those subkeys can contain subkeys, and so on, organized in folder-like fashion, much like a hard drive.

Keys and subkeys contain a value, which controls a particular setting. For example, this key:

HKEY_CURRENT_USER\Control Panel\Mouse\DoubleClickSpeed

determines the amount of time between mouse clicks that must elapse before Windows won't consider it to be a double-click. To set the amount of time, you change the key's value. In this case, the default value is 500, measured in milliseconds, and you can edit the Registry to change it to whatever value you want. You can also make the changes using the Mouse Properties dialog box (Start Control Panel Printers and Other Hardware Mouse). When you make changes to that dialog box, the changes are in turn made in the Registry, which ultimately controls the setting. In essence, the dialog box is merely a convenient front-end to the Registry.

A key can contain one or more values. Following are the five primary data types of values in the Registry:

REG_SZ (String value)

This data type is easy to understand and edit because it is made up of plain text and numbers. It is one of the most common data types in the Registry. The value for DoubleClickSpeed, mentioned earlier in this hack, is of this type.

REG_MULTI_SZ (String array value)

This data type contains several strings of plain text and numbers. The Registry Editor will let you edit these values, but it won't let you create them.

REG_EXPAND_SZ (Expanded string value)

This data type contains variables that Windows uses to point to the location of files. For example, to point to the location of the Luna theme file, the expanded string value in the Registry is %SystemRoot%\resources\Themes\Luna.theme.

REG_BINARY (Binary values)

This data type is made up of binary data: 0s and 1s. As a general rule, you won't edit binary values—instead you'll edit string values because they're made up of text and numbers.

REG_DWORD (DWORD values)

This data type is represented as a number. Sometimes a 0 turns on the key or 1 turns off the key, though it can use other numbers as well. While you see and edit the value as a number, such as 456, the Registry itself views the number as a hexadecimal number, 1C8.

Load disqus comments

0 comments