Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anything like Environment.SpecialFolder but for registry paths

Tags:

c#

.net

registry

I want to store some app information in the registry and I'm not sure where should I store it. I want the info to be for all users so I wouldn't use HKEY_CURRENT_USER. Maybe HKEY_LOCAL_MACHINE but then I'm not sure where in there. I don't know what are the standards for this and something like Environment.SpecialFolder but for registry paths or folders would be a lot safer and more elegant.

like image 758
Juan Avatar asked Dec 17 '22 18:12

Juan


1 Answers

Check the Microsoft.Win32.Registry object. There you can find some objects representing common registry paths, such as:

  • CurrentUser
  • LocalMachine
  • ClassesRoot
  • Users
  • PerformanceData
  • CurrentConfig
  • DynData

For example, if you want to access HKEY_CURRENT_USER:

Microsoft.Win32.RegistryKey key;
key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Names");
key.SetValue("Name", "Isabella");
key.Close();
like image 55
Daniel Peñalba Avatar answered Dec 19 '22 08:12

Daniel Peñalba