Reading registry keys
-
Hi all, I have a prob ,how we can read the registry keys in c# and display or write it into a text file Please help Thanks in advance Rakesh
-
Hi all, I have a prob ,how we can read the registry keys in c# and display or write it into a text file Please help Thanks in advance Rakesh
Do a search on the internet - you will get tons of answers. See here[^] for the first link my search returned.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick
-
Hi all, I have a prob ,how we can read the registry keys in c# and display or write it into a text file Please help Thanks in advance Rakesh
Navigate the Given Link to open Google Search Engine for tons of Answer for your question How to Read Registry Key[^] Hope it Will works for you. :-D
-
Hi all, I have a prob ,how we can read the registry keys in c# and display or write it into a text file Please help Thanks in advance Rakesh
Include the required Header Files and then open ur required key RegistryKey Key = Registry.CurrentUser; Once Opening the key open ur sub key as needed.. RegistryKey SubKey = Key.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"); Read the values of sub keys into string (if it is a string else required data type) string str = SubKey.GetValue("AppData").ToString(); Then ur almost done write this str value into file stream, so that ur task is acheived.... If u like my answer.... rate it :)Thanks
-
Include the required Header Files and then open ur required key RegistryKey Key = Registry.CurrentUser; Once Opening the key open ur sub key as needed.. RegistryKey SubKey = Key.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"); Read the values of sub keys into string (if it is a string else required data type) string str = SubKey.GetValue("AppData").ToString(); Then ur almost done write this str value into file stream, so that ur task is acheived.... If u like my answer.... rate it :)Thanks
Pardhu2 wrote:
Include the required Header Files
This is the C# forum.
-
Hi all, I have a prob ,how we can read the registry keys in c# and display or write it into a text file Please help Thanks in advance Rakesh
Here ya go. Paste this code into a class and you're all set:
using System;
using System.Linq;
using Microsoft.Win32;
using System.Collections.Generic;namespace Marois.Common.RegistryProcedures
{
public static class RegistryProcedures
{
#region enum BaseKeys
public enum BaseKey
{
HKEY_CLASSES_ROOT,
HKEY_CURRENT_CONFIG,
HKEY_CURRENT_USER,
HKEY_DYN_DATA,
HKEY_LOCAL_MACHINE,
HKEY_PERFORMANCE_DATA
}
#endregion#region Method CreateSubkey public static void CreateSubkey(BaseKey BaseKey, string KeyToAdd) { CreateSubkey(BaseKey, "", KeyToAdd); } public static void CreateSubkey(BaseKey BaseKey, string SubKey, string KeyToAdd) { RegistryKey baseKey; if (SubKey != "") baseKey = \_GetRegistryBaseKey(BaseKey).OpenSubKey(SubKey, true); else baseKey = \_GetRegistryBaseKey(BaseKey); if (baseKey == null && SubKey != "") { throw new Exception("Registry subkey not found"); } else { baseKey.CreateSubKey(KeyToAdd); } } #endregion #region Method DeleteSubkey public static void DeleteSubkey(BaseKey BaseKey, string SubKey) { RegistryKey baseKey = \_GetRegistryBaseKey(BaseKey); baseKey.DeleteSubKey(SubKey); } #endregion #region Method DeleteSubkeyTree public static void DeleteSubKeyTree(BaseKey BaseKey, string sSubKey) { RegistryKey baseKey = \_GetRegistryBaseKey(BaseKey); baseKey.DeleteSubKeyTree(sSubKey); } #endregion #region Method DeleteSubkeyTreeValues public static void DeleteSubkeyTreeValues(BaseKey BaseKey, string sSubKey) { List<string> nodeNames = GetSubKeyNodeNames(BaseKey, sSubKey); if(nodeNames.Count > 0) { RegistryKey baseKey = \_GetRegistryBaseKey(BaseKey); baseKey = baseKey.OpenSubKey(sSubKey, true); foreach(string nodeName in nodeNames) { baseKey.DeleteValue(nodeName); } } } #endregion #region Method DeleteValue