/// <summary> /// Loads the configuration. /// </summary> /// <returns>The system configuration.</returns> private static SystemConfiguration LoadConfiguration() { // Create the configuration object with the default configuration // which will be returned if no config is present in the system. var config = new SystemConfiguration { IsConfigurationPresent = false, LoggingMode = LoggingMode.Disabled }; // Open the SharpShell configuration key. // Open the local machine. using (var localMachineBaseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32)) { // Open the SharpShell Key. using (var sharpShellKey = localMachineBaseKey.OpenSubKey(SharpShellKey, RegistryKeyPermissionCheck.ReadSubTree, RegistryRights.ReadKey)) { // If we don't have the key, return the default config. if (sharpShellKey == null) return config; // Load the config. config.IsConfigurationPresent = true; config.LoggingMode = (LoggingMode)sharpShellKey.GetValue(LoggingModeValue, LoggingMode.Disabled); config.LogPath = (string)sharpShellKey.GetValue(LogPathValue, null); } } // Return the config. return config; }
/// <summary> /// Loads the configuration. /// </summary> /// <returns>The system configuration.</returns> private static SystemConfiguration LoadConfiguration() { // Create the configuration object with the default configuration // which will be returned if no config is present in the system. var config = new SystemConfiguration { IsConfigurationPresent = false, LoggingMode = LoggingMode.Disabled }; // Open the SharpShell configuration key. // Open the local machine. using (var localMachineBaseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32)) { // Open the SharpShell Key. using (var sharpShellKey = localMachineBaseKey.OpenSubKey(SharpShellKey, RegistryKeyPermissionCheck.ReadSubTree, RegistryRights.ReadKey)) { // If we don't have the key, return the default config. if (sharpShellKey == null) { return(config); } // Load the config. config.IsConfigurationPresent = true; config.LoggingMode = (LoggingMode)sharpShellKey.GetValue(LoggingModeValue, LoggingMode.Disabled); config.LogPath = (string)sharpShellKey.GetValue(LogPathValue, null); } } // Return the config. return(config); }