Author Topic: C# - Reading and Writing Registry Key Values  (Read 1343 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
C# - Reading and Writing Registry Key Values
« on: December 01, 2011, 06:54:40 pm »
You can use RegistryKey class defined in Microsoft.Win32 namespace.

Code: (C#)
//Source Code Listing

         // To access HKEY_LOCAL_MACHINE
        {
            Microsoft.Win32.RegistryKey key = Registry.LocalMachine.CreateSubKey("Software\\Links");
            Microsoft.Win32.RegistryKey key2 = key.CreateSubKey("Internet");
            key2.SetValue("#1", "www.softwareandfinance.com", RegistryValueKind.String);
         }
 
         // To do the same thing in HKEY_CURRENT_USER
        {
            Microsoft.Win32.RegistryKey key = Registry.CurrentUser.CreateSubKey("Software\\Links");
            Microsoft.Win32.RegistryKey key2 = key.CreateSubKey("Internet");
            key2.SetValue("#1", "www.softwareandfinance.com", RegistryValueKind.String);
         }

 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1