registry handling
-
Hi all, i need to write some program to handle registry please give me some links or some guidence to do something . this type of programming is new for me so plz guide in detail. thanks in advance. Keep Praying
-
Hi all, i need to write some program to handle registry please give me some links or some guidence to do something . this type of programming is new for me so plz guide in detail. thanks in advance. Keep Praying
This piece of code helped me alot, hope it'll work for you. /* *************************************** * ModifyRegistry.cs * --------------------------------------- * a very simple class * to read, write, delete and count * registry values with C# * --------------------------------------- * if you improve this code * please email me your improvement! * --------------------------------------- * by Francesco Natali * - fn.varie@libero.it - * ***************************************/ using System; // it's required for reading/writing into the registry: using Microsoft.Win32; // and for the MessageBox function: using System.Windows.Forms; namespace Utility.ModifyRegistry { /// /// An useful class to read/write/delete/count registry keys /// public class ModifyRegistry { private bool showError = false; /// /// A property to show or hide error messages /// (default = false) /// public bool ShowError { get { return showError; } set { showError = value; } } private string subKey = "SOFTWARE\\" + Application.ProductName.ToUpper(); /// /// A property to set the SubKey value /// (default = "SOFTWARE\\" + Application.ProductName.ToUpper()) /// public string SubKey { get { return subKey; } set { subKey = value; } } private RegistryKey baseRegistryKey = Registry.LocalMachine; /// /// A property to set the BaseRegistryKey value. /// (default = Registry.LocalMachine) /// public RegistryKey BaseRegistryKey { get { return baseRegistryKey; } set { baseRegistryKey = value; } } /* ************************************************************************** * **************************************************************************/ /// /// To read a registry key. /// input: KeyName (string) /// output: value (string) /// public string Read(string KeyName) { // Opening the registry key RegistryKey rk = baseRegistryKey ; // Open a subKey as read-only RegistryKey sk1 = rk.OpenSubKey(subKey); // If the RegistrySubKey doesn't exist -> (null) if ( sk1 == null ) { return null; } else { try { // If the RegistryKey exists I get its value // or null is returned. return (string)sk1.GetValue(KeyName.ToUpper()); } catch (Exception e)