45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Microsoft.Win32;
|
|
//using System.Deployment.Application;
|
|
using System.Security.Permissions;
|
|
|
|
namespace SuperMap.RealEstate.SecurityDevice.Setup.npPlugin
|
|
{
|
|
/// <summary />
|
|
public static class RegistryHelper
|
|
{
|
|
const string _SubKey = "SOFTWARE";
|
|
/// <summary />
|
|
public static void Write(string SubKeyName, string Name, string Value)
|
|
{
|
|
string _SubKeyName = _SubKey + "\\" + SubKeyName;
|
|
using (RegistryKey _RegistryKey = Registry.LocalMachine.CreateSubKey(_SubKeyName))
|
|
{
|
|
_RegistryKey.SetValue(Name, Value);
|
|
}
|
|
}
|
|
/// <summary />
|
|
public static string Read(string SubKeyName, string Name)
|
|
{
|
|
try
|
|
{
|
|
string _SubKeyName = _SubKey + "\\" + SubKeyName;
|
|
using (RegistryKey _RegistryKey = Registry.CurrentUser.OpenSubKey(_SubKeyName))
|
|
{
|
|
if (_RegistryKey == null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
return _RegistryKey.GetValue(Name).ToString();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
}
|
|
}
|