Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Open/Creates a Base Key in the Registry

// open a Base Key in the registry

       public static RegistryKey GetKey(string baseKey)
        {
            RegistryKey key;
            try
            {
                key = Registry.LocalMachine.OpenSubKey(baseKey, true);

                if (key == null)
                {
                    key = Registry.LocalMachine.CreateSubKey(baseKey);
                }
                else
                {
                    MessageBox.Show("Base key resolved");
                }
            }
            catch (Exception e)
            {
                return null;
            }
            return key;
        }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS