Tuesday, April 23, 2013

Read and Write Registry Key In C#

static string Regname = "Registryname";
        public bool writeRegistryKey(string Key, string value)
        {
            try
            {
                Microsoft.Win32.RegistryKey key; key =
                                                Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(Regname);
                key.SetValue(Key, value); key.Close(); return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return false;
            }
        }
        public string readRegistryKey(string Value)
        {
            try
            {
                string keyValue = null;
                Microsoft.Win32.RegistryKey key; key =
                           Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(Regname);
                keyValue = key.GetValue(id).ToString();
                key.Close();
                return keyValue;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return null;
            }
        }

3 comments:

  1. Nice C tutorial thanks


    Nice and very good collection of books
    www.khanbooks.net

    ReplyDelete
  2. Ankur Bhargav'S C Bolg >>>>> Download Now

    >>>>> Download Full

    Ankur Bhargav'S C Bolg >>>>> Download LINK

    >>>>> Download Now

    Ankur Bhargav'S C Bolg >>>>> Download Full

    >>>>> Download LINK uU

    ReplyDelete
  3. Ankur Bhargav'S C Bolg >>>>> Download Now

    >>>>> Download Full

    Ankur Bhargav'S C Bolg >>>>> Download LINK

    >>>>> Download Now

    Ankur Bhargav'S C Bolg >>>>> Download Full

    >>>>> Download LINK hx

    ReplyDelete