Globals.RegistryAccess.setValue C# (CSharp) Method

setValue() public static method

Sets a registry value
public static setValue ( RegistryKey mainKey, string subKey, string valueName, object value ) : bool
mainKey Microsoft.Win32.RegistryKey A Windows.Win32.Registry value (Halo2 uses CurrentUser)
subKey string The path to the value (Halo 2 uses RegistryAccess.RegPaths)
valueName string The Label of the value (Halo 2 uses RegistryAccess.RegNames)
value object The new value
return bool
        public static bool setValue(RegistryKey mainKey, string subKey, string valueName, object value)
        {
            RegistryKey the_Reg;
            try
            {
                the_Reg = mainKey.CreateSubKey(@subKey);
                the_Reg.SetValue(valueName, value);
                the_Reg.Close();
            }
            catch
            {
                return false;
            }

            return true;
        }

Usage Example

示例#1
0
 private void PluginSetSelector_FormClosed(object sender, FormClosedEventArgs e)
 {
     // Clear any old plugin listings
     RegistryAccess.removeKey(Microsoft.Win32.Registry.CurrentUser,
                              RegistryAccess.RegPaths.Halo2 + "PluginSets\\");
     // We must always have at least a Default plugin
     if (pluginInfo.Names.Count == 0)
     {
         pluginInfo.Names.Add("Default");
         pluginInfo.Paths.Add(Prefs.pathPluginsFolder);
     }
     // Write all the plugins back to the registry
     for (int i = 0; i < pluginInfo.Names.Count; i++)
     {
         RegistryAccess.setValue(Microsoft.Win32.Registry.CurrentUser,
                                 RegistryAccess.RegPaths.Halo2 + "PluginSets\\",
                                 pluginInfo.Names[i],
                                 pluginInfo.Paths[i]);
     }
 }
All Usage Examples Of Globals.RegistryAccess::setValue