ClassAssistance.Slave/Helper/RegistryHelper.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Win32;
namespace ClassAssistance.Slave.Helper
{
public static class RegistryHelper
{
public static bool AddRegistryKeyValue(RegistryHive hive, string path, string name, string value, bool addQuotes = false) =>
RegistryKey.OpenBaseKey(hive, RegistryView.Registry64).OpenWritableSubKeySafe(path,
key =>
{
if (addQuotes && !value.StartsWith("\"") && !value.EndsWith("\""))
value = "\"" + value + "\"";
key.SetValue(name, value);
return true;
});
public static bool OpenReadonlySubKey(RegistryHive hive, string path, Func<RegistryKey, bool> onSuccess)
{
try
{
using (var key = RegistryKey.OpenBaseKey(hive, RegistryView.Registry64).OpenSubKey(path, false))
{
if (key == null)
return false;
return onSuccess(key);
}
}
catch
{
return false;
}
}
public static bool DeleteRegistryKeyValue(RegistryHive hive, string path, string name) =>
RegistryKey.OpenBaseKey(hive, RegistryView.Registry64).OpenWritableSubKeySafe(path,
key =>
{
key.DeleteValue(name, true);
return true;
});
private static bool IsNameOrValueNull(this string keyName, RegistryKey key) =>
string.IsNullOrEmpty(keyName) || (key == null);
public static string GetValueSafe(this RegistryKey key, string keyName, string defaultValue = "")
{
try
{
return key.GetValue(keyName, defaultValue).ToString();
}
catch
{
return defaultValue;
}
}
后面还有 47 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
