Skip to Main Content
C# in a Nutshell
book

C# in a Nutshell

by Ben Albahari, Ted Neward, Peter Drayton
March 2002
Intermediate to advanced content levelIntermediate to advanced
864 pages
31h 8m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell

Name

RegistryKey

Synopsis

The RegistryKey class contains the core functionality for reading and writing to the Windows registry. Each RegistryKey object represents an individual key in the registry. You can use the properties of this class to find out how many values this key contains (ValueCount), how many subkeys (SubKeyCount) there are, and the fully qualified key name (Name).

To open a subkey for modification, use the overloaded version of the OpenSubKey() method — which allows you to specify the writable parameter — and set it to true. You can open subkeys that are several levels deep by separating keys with a backslash (\). In C#, the backslash must be escaped, as in mykey.OpenKey("Software\\Microsoft"). You can also use methods such as CreateSubKey() and DeleteSubKey(). In the registry, keys are logical groupings, and values are the entries used to store the actual data. You can use the GetValue(), SetValue(), and DeleteValue() methods to manipulate a named value in the current key.

Changes to the registry are propagated across the system automatically, and are flushed to disk automatically by the system. You should never need to use methods such as Flush(), unless you require absolute certainty that a registry change has been written to disk. The OpenRemoteBaseKey() method opens the registry on a remote computer, provided both machines are running the remote registry service and have remote administration enabled.

public sealed class RegistryKey : MarshalByRefObject : IDisposable ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# 8.0 in a Nutshell

C# 8.0 in a Nutshell

Joseph Albahari, Eric Johannsen
C# 10 in a Nutshell

C# 10 in a Nutshell

Joseph Albahari
C# in a Nutshell, Second Edition

C# in a Nutshell, Second Edition

Peter Drayton, Ben Albahari, Ted Neward
Code like a Pro in C#

Code like a Pro in C#

Jort Rodenburg

Publisher Resources

ISBN: 0596001819Catalog PageErrata