using Microsoft.Win32;
using System;
namespace Y.Utils.Net20.ComputerUtils
{
public class RegisterTool
{
///
/// 写入注册表项
///
/// SOFTWARE\\NC_VideoConferenceSystem
/// RegTime
/// yyyy-MM-dd hh:mm:ss
public static bool Write(string key, string name, string value)
{
try
{
RegistryKey RKey = Registry.LocalMachine.OpenSubKey(key, true);
if (RKey == null)
RKey = Registry.LocalMachine.CreateSubKey(key);
RKey.SetValue(name, value);
return true;
}
catch (Exception e)
{
return false;
}
}
///
/// 读取注册表项
///
/// SOFTWARE\\NC_VideoConferenceSystem
/// Path
///
public static string Read(string key, string name)
{
try
{
RegistryKey RKey = Registry.LocalMachine.OpenSubKey(key, true);
if (RKey != null)
{
return RKey.GetValue(name) != null ? RKey.GetValue(name).ToString() : "";
}
}
catch (Exception e) { }
return null;
}
public static bool Delete(string key, string name)
{
try
{
RegistryKey RKey = Registry.LocalMachine.OpenSubKey(key, true);
if (RKey != null && RKey.GetValue(name) != null)
RKey.DeleteValue(name);
return true;
}
catch (Exception e)
{
return false;
}
}
}
}