Search code examples
c#.netregistry

Working with Windows Registry from .NET


my .net app needs to store some persistent data and since it is possible that it runs in an environment where it cant write to disk, i would like to use the registry for it.

  1. are there any conventions about the path where an application is writing to?

  2. are there any tools or libraries that make reading and writing the registry from .net more convenient? i need to mostly write simple datatypes and datastructures like lists.

  3. any other best practices or tips & tricks that should be know when working with the registry?


Solution

  • Writing to the registry is a little frowned on nowadays, however if you must:

    Put settings for the current user in: HKEY_CURRENT_USER\Software\Your Company\Your App

    Put settings for all users in: HKEY_LOCAL_MACHINE\Software\Your Company\Your App

    Use the Registry class in the .NET framework to read and write registry keys and values:

    http://msdn.microsoft.com/en-us/library/microsoft.win32.registry(v=vs.110).aspx