15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

eading <strong>and</strong> Writing to the registry ❘ 807<br />

regedit has a tree view/list view-style user interface similar to Windows Explorer, which matches the<br />

hierarchical structure of the registry itself. However, you will see some key differences shortly.<br />

figure 29-16<br />

In a file system, the topmost-level nodes can be thought of as being the partitions on your disks, C:\, D:\,<br />

<strong>and</strong> so on. In the registry, the equivalent to a partition is the registry hive. It is not possible to change the<br />

existing hives — they are fixed, <strong>and</strong> there are seven of them, although only five are actually visible through<br />

regedit:<br />

➤<br />

➤<br />

➤<br />

➤<br />

➤<br />

HKEY_CLASSES_ROOT (HKCR) contains details of types of files on the system (.txt, .doc, <strong>and</strong> so on)<br />

<strong>and</strong> which applications are able to open files of each type. It also contains registration information<br />

for all COM components (this latter area is usually the largest single area of the registry because<br />

Windows, these days, comes with a huge number of COM components).<br />

HKEY_CURRENT_USER (HKCU) contains details of user preferences for the user currently logged on<br />

to the machine locally. These settings include desktop settings, environment variables, network <strong>and</strong><br />

printer connections, <strong>and</strong> other settings that define the user operating environment of the user.<br />

HKEY_LOCAL_MACHINE (HKLM) is a huge hive that contains details of all software <strong>and</strong> hardware<br />

installed on the machine. These settings are not user-specific but are for all users that log on to the<br />

machine. This hive also includes the HKCR hive; HKCR is actually not really an independent hive in<br />

its own right but is simply a convenient mapping onto the registry key HKLM/SOFTWARE/Classes.<br />

HKEY_USERS (HKUSR) contains details of user preferences for all users. As you might guess, it also<br />

contains the HKCU hive, which is simply a mapping onto one of the keys in HKEY_USERS.<br />

HKEY_CURRENT_CONFIG (HKCF) contains details of hardware on the machine.<br />

The remaining two keys contain information that is temporary <strong>and</strong> that changes frequently:<br />

➤<br />

➤<br />

HKEY_DYN_DATA is a general container for any volatile data that needs to be stored somewhere in the<br />

registry.<br />

HKEY_PERFORMANCE_DATA contains information concerning the performance of running applications.<br />

Within the hives is a tree structure of registry keys. Each key is in many ways analogous to a folder or file on<br />

the file system. However, there is one very important difference. The file system distinguishes between files<br />

(which are there to contain data) <strong>and</strong> folders (which are primarily there to contain other files or folders), but<br />

in the registry there are only keys. A key may contain both data <strong>and</strong> other keys.<br />

If a key contains data, it will be presented as a series of values. Each value will have an associated name,<br />

data type, <strong>and</strong> data. In addition, a key can have a default value, which is unnamed.<br />

You can see this structure by using regedit to examine registry keys. Figure 29-17 shows the contents of<br />

the key HKCU\Control Panel\Appearance, which contains the details of the chosen color scheme of the<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!