using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Win32; namespace Aitex.UI.Charting.ViewModel { /// /// 注册表工具 /// public class RegEdit { /// /// 注册表读取 /// /// /// /// /// public static string ReadRegedit(string appName, string keyName) { if (string.IsNullOrEmpty(appName) || string.IsNullOrEmpty(keyName)) return string.Empty; string ret = string.Empty; RegistryKey hklm = Registry.CurrentUser; RegistryKey software = hklm.OpenSubKey("Software", false); RegistryKey aimdir = software.OpenSubKey(appName); if (aimdir != null) { ret = Convert.ToString(aimdir.GetValue(keyName)); aimdir.Close(); } software.Close(); hklm.Close(); return ret; } /// /// 注册表修改 /// /// /// /// /// public static bool WriteRegedit(string appName, string keyName, string keyValue) { if (string.IsNullOrEmpty(appName) || string.IsNullOrEmpty(keyName)) return false; RegistryKey hklm = Registry.CurrentUser; RegistryKey software = hklm.OpenSubKey("Software", true); RegistryKey aimdir = software.CreateSubKey(appName); aimdir.SetValue(keyName, keyValue); aimdir.Close(); software.Close(); hklm.Close(); return true; } } }