Saturday, March 17, 2012

Read and Write the Windows Registry C#

using System;
using Microsoft.Win32;

namespace TyroDeveloperDLL
{
    public class WindowsRegistry
    {
        RegistryKey registryAccess;
        public void WriteValue(string pKey, string pValue) {
            registryAccess = Registry.Users;
            registryAccess = registryAccess.OpenSubKey(".DEFAULT", true);

            registryAccess.SetValue(pKey, pValue, RegistryValueKind.String);

            registryAccess.Close();
        }
        public string ReadValue(string pKey, string pDefault) {
            registryAccess = Registry.Users;
            string val = "";
            registryAccess = registryAccess.OpenSubKey(".DEFAULT", true);

            val = registryAccess.GetValue(pKey, pDefault).ToString();

            registryAccess.Close();
            return (val);
        }
    }
}

Please visit: www.TyroDeveloper.com

Please Click on +1

No comments:

Post a Comment