RegistryKey

RegistryKey marshal by reference, disposable

Microsoft.Win32 (mscorlib.dll) sealed class

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( ) methodwhich allows you to specify the writable parameterand 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 {  // Public Instance Properties  public string  Name  {get; }    public int  SubKeyCount  {get; }    public int  ValueCount  {get; }  // Public Static Methods  public static RegistryKey  OpenRemoteBaseKey  (RegistryHive   hKey   , string   machineName   );  // Public Instance Methods  public void  Close  ( );    public RegistryKey  CreateSubKey  (string   subkey   );    public void  DeleteSubKey  (string   subkey   );    public void  DeleteSubKey  (string   subkey   , bool   throwOnMissingSubKey   );    public void  DeleteSubKeyTree  (string   subkey   );    public void  DeleteValue  (string   name   );    public void  DeleteValue  (string   name   , bool   throwOnMissingValue   );    public void  Flush  ( );    public string[ ]  GetSubKeyNames  ( );    public object  GetValue  (string   name   );    public object  GetValue  (string   name   , object   defaultValue   );    public string[ ]  GetValueNames  ( );    public RegistryKey  OpenSubKey  (string   name   );    public RegistryKey  OpenSubKey  (string   name   , bool   writable   );    public void  SetValue  (string   name   , object   value   );    public override string  ToString  ( );  // overrides object   // Protected Instance Methods  protected override void  Finalize  ( );  // overrides object  } 

Hierarchy

System.Object System.MarshalByRefObject RegistryKey(System.IDisposable)



C# in a Nutshell
C # in a Nutshell, Second Edition
ISBN: 0596005261
EAN: 2147483647
Year: 2005
Pages: 963

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net