本文整理汇总了C#中RegistryHive类的典型用法代码示例。如果您正苦于以下问题:C# RegistryHive类的具体用法?C# RegistryHive怎么用?C# RegistryHive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegistryHive类属于命名空间,在下文中一共展示了RegistryHive类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HBinSizeShouldNotMatchReadSize
public void HBinSizeShouldNotMatchReadSize()
{
var r = new RegistryHive(@"..\..\Hives\SAM_DUPENAME");
//if you don't call parse, it wont match
Check.That(r.Header.Length).IsNotEqualTo(r.HBinRecordTotalSize);
}
示例2: add_key
private void add_key(IList<RegistryKey> keys, RegistryHive hive, RegistryView view)
{
FaultTolerance.try_catch_with_logging_exception(
() => keys.Add(RegistryKey.OpenBaseKey(hive, view)),
"Could not open registry hive '{0}' for view '{1}'".format_with(hive.to_string(), view.to_string()),
logWarningInsteadOfError: true);
}
示例3: GetRegBaseKey
public static RegistryKey GetRegBaseKey(RegistryHive hive)
{
#if NET4
return RegistryKey.OpenBaseKey(hive, (Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32));
#else
RegistryKey result = null;
switch (hive)
{
case RegistryHive.ClassesRoot:
break;
case RegistryHive.CurrentConfig:
break;
case RegistryHive.CurrentUser:
break;
case RegistryHive.DynData:
break;
case RegistryHive.PerformanceData:
break;
case RegistryHive.Users:
break;
default:
result = Microsoft.Win32.Registry.LocalMachine;
break;
}
return result;
#endif
}
示例4:
public RegistrySettingsProvider
(RegistryHive hKey, RegistryView view = RegistryView.Default, string baseKey = null)
{
this.hKey = hKey;
this.view = view;
this.baseKey = baseKey ?? ProductInfo.Company + "\\" + ProductInfo.Product;
}
示例5: deleteRegistryKey
private void deleteRegistryKey(RegistryHive hive, string key)
{
using (var reg = RegistryKey.OpenBaseKey(hive, RegistryView.Default))
{
reg.DeleteSubKey(key);
}
}
示例6: RemoveRegistrySubKey
/// <summary>
/// Удалить ключ реестра
/// </summary>
/// <param name="root">Ветка реестра</param>
/// <param name="key">Ключ для удаления</param>
public static void RemoveRegistrySubKey(RegistryHive root, string key)
{
switch (root)
{
case RegistryHive.ClassesRoot:
Registry.ClassesRoot.DeleteSubKey(key);
break;
case RegistryHive.CurrentUser:
Registry.CurrentUser.DeleteSubKey(key);
break;
case RegistryHive.LocalMachine:
Registry.LocalMachine.DeleteSubKey(key);
break;
case RegistryHive.Users:
Registry.Users.DeleteSubKey(key);
break;
case RegistryHive.CurrentConfig:
Registry.CurrentConfig.DeleteSubKey(key);
break;
}
}
示例7: GetRawRegistryKeyTimestamp
private Int64 GetRawRegistryKeyTimestamp(RegistryHive hive, string keyname)
{
if (String.IsNullOrEmpty(keyname))
{
return 0; // Otherwise the function opens HKLM (or HKCU) again.
}
UIntPtr hkey = OpenKey(hive, keyname, KEY_QUERY_VALUE);
if (hkey == UIntPtr.Zero)
{
return 0; // Didn't open key
}
Int64 timestamp;
uint result2 = NativeMethods.RegQueryInfoKey(
hkey, IntPtr.Zero,
IntPtr.Zero, IntPtr.Zero,
IntPtr.Zero, IntPtr.Zero,
IntPtr.Zero, IntPtr.Zero,
IntPtr.Zero, IntPtr.Zero,
IntPtr.Zero, out timestamp);
if (result2 != 0)
{
timestamp = 0; // Failed, don't return whatever value was supplied.
}
NativeMethods.RegCloseKey(hkey);
return timestamp;
}
示例8: OpenBaseKey
public IRegistryKey OpenBaseKey(
RegistryHive hKey,
RegistryView view
)
{
return new RegistryKeyWrap(RegistryKey.OpenBaseKey(hKey, view));
}
示例9: DeleteRegistryKeyValue
public static bool DeleteRegistryKeyValue(RegistryHive hive, string path, string name) =>
RegistryKey.OpenBaseKey(hive, RegistryView.Registry64).OpenWritableSubKeySafe(path,
(key) =>
{
key.DeleteValue(name, true);
return true;
});
示例10: Bin
public Bin(RegistryHive hive, Stream stream)
{
_hive = hive;
_fileStream = stream;
_streamPos = stream.Position;
stream.Position = _streamPos;
byte[] buffer = Utilities.ReadFully(stream, 0x20);
_header = new BinHeader();
_header.ReadFrom(buffer, 0);
_fileStream.Position = _streamPos;
_buffer = Utilities.ReadFully(_fileStream, _header.BinSize);
// Gather list of all free cells.
_freeCells = new List<Range<int, int>>();
int pos = 0x20;
while (pos < _buffer.Length)
{
int size = Utilities.ToInt32LittleEndian(_buffer, pos);
if (size > 0)
{
_freeCells.Add(new Range<int, int>(pos, size));
}
pos += Math.Abs(size);
}
}
示例11: CleanUpRegistry
private static void CleanUpRegistry(RegistryHive hive)
{
var regValueNames = new[]{ Reg_LoggingEnabled,
Reg_DebugLogEnabled,
Reg_FileLogEnabled,
Reg_Severity,
Reg_Path};
using (RegistryKey rootKey = RegistryKey.OpenBaseKey(hive, RegistryView.Default))
{
using (RegistryKey key = rootKey.OpenSubKey(TestKeyPath, true))
{
if (key != null)
{
foreach (var regValueName in regValueNames)
{
try
{
key.DeleteValue(regValueName);
}
catch (ArgumentException)
{
// Assumption: ArgumentExceptions caused by values that are not present
}
}
}
}
}
}
示例12: DoRun
protected override void DoRun()
{
using (Stream fileStream = File.OpenRead(_bcdFile.Value))
{
using (RegistryHive hive = new RegistryHive(fileStream))
{
Store bcdDb = new Store(hive.Root);
foreach (var obj in bcdDb.Objects)
{
Console.WriteLine(obj.FriendlyName + ":");
Console.WriteLine(" Id: " + obj.ToString());
Console.WriteLine(" Type: " + obj.ObjectType);
Console.WriteLine(" App Image Type: " + obj.ApplicationImageType);
Console.WriteLine(" App Type: " + obj.ApplicationType);
Console.WriteLine(" App can inherit: " + obj.IsInheritableBy(ObjectType.Application));
Console.WriteLine(" Dev can inherit: " + obj.IsInheritableBy(ObjectType.Device));
Console.WriteLine(" ELEMENTS");
foreach (var elem in obj.Elements)
{
Console.WriteLine(" " + elem.FriendlyName + ":");
Console.WriteLine(" Id: " + elem.ToString());
Console.WriteLine(" Class: " + elem.Class);
Console.WriteLine(" Format: " + elem.Format);
Console.WriteLine(" Value: " + elem.Value);
}
Console.WriteLine();
}
}
}
}
示例13: RegistryKeyMonitor
public RegistryKeyMonitor(
RegistryHive hive,
string key,
RegistryNotifyFilter filter,
RegistryKeyWatch watch,
KeyChangedDelegate keyChanged,
ExceptionRaisedDelegate exceptionRaised)
{
if (keyChanged == null)
{
throw new ArgumentNullException(nameof(keyChanged));
}
if (exceptionRaised == null)
{
throw new ArgumentNullException(nameof(exceptionRaised));
}
RegistryHive = hive;
Key = key;
Filter = filter;
WatchSubTree = watch == RegistryKeyWatch.KeyAndSubKeys;
this.keyChanged = keyChanged;
this.exceptionRaised = exceptionRaised;
StartMonitor();
}
示例14: SetValue
public void SetValue(RegistryHive hive, string registryValueName, object value)
{
RegistryKey rootKey = RegistryKey.OpenBaseKey(hive, RegistryView.Default);
RegistryKey testKey = rootKey.CreateSubKey(TestKeyPath);
Assert.NotNull(testKey);
testKey.SetValue(registryValueName, value);
}
示例15: CreateRegistryKey
public static RegistryKeyOptions CreateRegistryKey(this ProtoServer protoServer, RegistryHive hive, string name, Action<RegistryKeyOptions> options)
{
var proto = CreateRegistryKey(protoServer, hive, name);
if (options != null)
options(proto);
return proto;
}