using System; using System.Text; using Microsoft.Win32; namespace NewPosInstaller { /// /// ubSys.Registry /// public class Registry { /// /// 레스트리 값 가져오기 /// /// /// /// /// public static string GetValue(Microsoft.Win32.RegistryKey regKey, string subKey, string name) { string retValue = string.Empty; ; try { using (regKey = regKey.OpenSubKey(subKey, true)) { if (regKey != null) retValue = System.Convert.ToString(regKey.GetValue(name)); regKey.Close(); } } catch (Exception ex) { ComLog.WriteLog(ComLog.Level.Exception , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" , ex.Message); retValue = string.Empty; } return retValue; } /// /// 레지스트리에 값 쓰기 /// /// /// /// /// /// public static bool SetValue(Microsoft.Win32.RegistryKey regKey, string subKey, string name, string value) { try { using (regKey = regKey.CreateSubKey(subKey, RegistryKeyPermissionCheck.ReadWriteSubTree)) { regKey.SetValue(name, value); regKey.Flush(); regKey.Close(); } return true; } catch (Exception ex) { ComLog.WriteLog(ComLog.Level.Exception , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" , ex.Message); return false; } } /// /// 레지스트리에 값 쓰기 /// /// /// /// /// /// public static bool SetValue(Microsoft.Win32.RegistryKey regKey, string subKey, string name, long value) { try { using (regKey = regKey.CreateSubKey(subKey, RegistryKeyPermissionCheck.ReadWriteSubTree)) { regKey.SetValue(name, value, RegistryValueKind.DWord); regKey.Flush(); regKey.Close(); } return true; } catch (Exception ex) { ComLog.WriteLog(ComLog.Level.Exception , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" , ex.Message); return false; } } public static bool IsExistKey(Microsoft.Win32.RegistryKey regKey, string subKey) { bool retValue = false; try { using (Microsoft.Win32.RegistryKey key = regKey.OpenSubKey(subKey)) { if (key != null) retValue = true; } } catch (Exception ex) { ComLog.WriteLog(ComLog.Level.Exception , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" , ex.Message); retValue = false; } return retValue; } } }