.

Saving and Loading data in the registry (old – use new!)

namespace Bitlink.Core
{
    using Microsoft.Win32;

    public class RegistryAccess
    {
        private readonly string _registryKey;

        public RegistryAccess(string registryKey)
        {
            _registryKey = registryKey;
        }

        //Loading a value:
        public string LoadSettingFromRegistry(string settingKey)
        {
            RegistryKey MyKey = Registry.CurrentUser.OpenSubKey(_registryKey);
            if (MyKey == null)
                return null;
            else
            {
                var ValFromReg = (string) MyKey.GetValue(settingKey);
                return (ValFromReg != null) ? ValFromReg : null;
                MyKey.Close();
            }
        }

        //Saving a value:
        public void SaveSettingToRegistry(string settingKey, string value)
        {
            RegistryKey MyKey = Registry.CurrentUser.CreateSubKey(_registryKey);
            MyKey.SetValue(settingKey, value);
            MyKey.Close();
        }
    }
}
<strong></strong>

What's your thoughts on this?

*

Protected by WP Anti Spam