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

About this user

Dave http://pedotnet.blogspot.com

« 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

   1  
   2         public static RegistryKey GetKey(string baseKey)
   3          {
   4              RegistryKey key;
   5              try
   6              {
   7                  key = Registry.LocalMachine.OpenSubKey(baseKey, true);
   8  
   9                  if (key == null)
  10                  {
  11                      key = Registry.LocalMachine.CreateSubKey(baseKey);
  12                  }
  13                  else
  14                  {
  15                      MessageBox.Show("Base key resolved");
  16                  }
  17              }
  18              catch (Exception e)
  19              {
  20                  return null;
  21              }
  22              return key;
  23          }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS