/// <summary>Sets given value for registry key with given name</summary> /// <param name="isAdminForced">indicates that the previous value was enforced by admin and can't be changed</param> /// <param name="name">name associated with value</param> /// <param name="value">value</param> /// <param name="rvk">type of registry value</param> private static void SetRegistryValue(bool isAdminForced, string name, object value, RegistryValueKind rvk) { if (!isAdminForced) { UserSettingsRegistryKey.SetValue(name, value, rvk); } }
/// <summary>Returns REG_SZ registry value with specified name retrieved from admin or user key</summary> /// <param name="isAdminForced">indicates that user key value should be ignored if any</param> /// <param name="name">name associated with value</param> /// <returns>string value associated with given name</returns> private static string GetStringRegistryValue(bool isAdminForced, string name) { if (isAdminForced) { return(AdminSettingsRegistryKey.GetValue(name, null) as string); } return(UserSettingsRegistryKey.GetValue(name, null) as string); }
/// <summary>Receives DWORD registry value associated with specified name retrieved from admin or user key</summary> /// <param name="isAdminForced">indicates that user key value should be ignored if any</param> /// <param name="name">name associated with value</param> /// <returns>numeric value associated with given name</returns> private static int GetIntRegistryValue(bool isAdminForced, string name) { if (isAdminForced) { return((int)AdminSettingsRegistryKey.GetValue(name, 0)); } return((int)UserSettingsRegistryKey.GetValue(name, 0)); }
/// <summary>Saves settings into registry if not already</summary> internal static void PersistSettings() { SetRegistryValue(false, "isMigrated", 1, RegistryValueKind.DWord); UserSettingsRegistryKey.Flush(); }