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

Open/Creates a Base Key in the Registry (See related posts)

// 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;
        }

You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts