반응형
public static class RegistryUtil
{
public static string GetValue(string path, string keyName)
{
try
{
string strValue = null;
RegistryKey regKey = Registry.CurrentUser.CreateSubKey(path, RegistryKeyPermissionCheck.ReadWriteSubTree);
var value = regKey.GetValue(keyName);
if (value != null)
{
strValue = value.ToString();
}
return strValue;
}
catch (Exception)
{
return string.Empty;
}
}
public static void SetKey(string path, string name, string value)
{
RegistryKey regKey = Registry.CurrentUser.CreateSubKey(path, RegistryKeyPermissionCheck.ReadWriteSubTree);
regKey.SetValue(name, value, RegistryValueKind.String);
}
public static void DeleteKey(string path, string name)
{
RegistryKey regKey = Registry.CurrentUser.CreateSubKey(path, RegistryKeyPermissionCheck.ReadWriteSubTree);
regKey.DeleteValue(name, false);
}
public static void DeleteRegistry(string path)
{
Registry.CurrentUser.DeleteSubKey(path);
}
public static void SetSoftwareKey(string path, string name, string value)
{
SetKey(@"Software\" + path, name, value);
}
public static string GetSoftwareValue(string path, string name)
{
return GetValue(@"Software\" + path, name);
}
}
반응형
'[====== Development ======] > C#' 카테고리의 다른 글
[WPF] 특정 UIElement를 캡쳐하여 이미지 파일로 저장 (0) | 2022.03.07 |
---|---|
[WPF] Read BitmapImage From File (0) | 2022.03.07 |
[C#] IniFile Helper Class (0) | 2022.03.07 |
[WPF] TextBox Delay TextChanged Event (0) | 2022.03.03 |
[WPF] TextBox 정수만 입력 또는 실수만 입력 (0) | 2022.03.03 |