Skip to Main Content
C# in a Nutshell, Second Edition
book

C# in a Nutshell, Second Edition

by Peter Drayton, Ben Albahari, Ted Neward
August 2003
Intermediate to advanced content levelIntermediate to advanced
928 pages
32h 1m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell, Second Edition

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# in a Nutshell

C# in a Nutshell

Ben Albahari, Ted Neward, Peter Drayton
C# 7.0 in a Nutshell

C# 7.0 in a Nutshell

Joseph Albahari, Ben Albahari
C# Cookbook, 2nd Edition

C# Cookbook, 2nd Edition

Jay Hilyard, Stephen Teilhet
C# Cookbook

C# Cookbook

Joe Mayo

Publisher Resources

ISBN: 0596005261Catalog PageErrata