From a251a9ee5a1ab8b425703bb5e817120c915732a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=B6glinger-Stelzer?= Date: Wed, 24 Oct 2018 20:58:18 +0200 Subject: [PATCH] Clean-up --- DerpingDrivers/Util/OSVersionInfo.cs | 61 ++++++++++++++-------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/DerpingDrivers/Util/OSVersionInfo.cs b/DerpingDrivers/Util/OSVersionInfo.cs index 5578f07..025ef1c 100644 --- a/DerpingDrivers/Util/OSVersionInfo.cs +++ b/DerpingDrivers/Util/OSVersionInfo.cs @@ -53,32 +53,32 @@ namespace DerpingDrivers.Util #region Registry Methods - private static string RegistryRead(string RegistryPath, string Field, string DefaultValue) + private static string RegistryRead(string registryPath, string field, string defaultValue) { - var rtn = ""; - var backSlash = ""; - var newRegistryPath = ""; + var rtn = string.Empty; + var backSlash = string.Empty; + var newRegistryPath = string.Empty; try { - RegistryKey OurKey = null; - var split_result = RegistryPath.Split('\\'); + RegistryKey ourKey = null; + var splitResult = registryPath.Split('\\'); - if (split_result.Length > 0) + if (splitResult.Length > 0) { - split_result[0] = split_result[0].ToUpper(); // Make the first entry uppercase... + splitResult[0] = splitResult[0].ToUpper(); // Make the first entry uppercase... - if (split_result[0] == "HKEY_CLASSES_ROOT") OurKey = Registry.ClassesRoot; - else if (split_result[0] == "HKEY_CURRENT_USER") OurKey = Registry.CurrentUser; - else if (split_result[0] == "HKEY_LOCAL_MACHINE") OurKey = Registry.LocalMachine; - else if (split_result[0] == "HKEY_USERS") OurKey = Registry.Users; - else if (split_result[0] == "HKEY_CURRENT_CONFIG") OurKey = Registry.CurrentConfig; + if (splitResult[0] == "HKEY_CLASSES_ROOT") ourKey = Registry.ClassesRoot; + else if (splitResult[0] == "HKEY_CURRENT_USER") ourKey = Registry.CurrentUser; + else if (splitResult[0] == "HKEY_LOCAL_MACHINE") ourKey = Registry.LocalMachine; + else if (splitResult[0] == "HKEY_USERS") ourKey = Registry.Users; + else if (splitResult[0] == "HKEY_CURRENT_CONFIG") ourKey = Registry.CurrentConfig; - if (OurKey != null) + if (ourKey != null) { - for (var i = 1; i < split_result.Length; i++) + for (var i = 1; i < splitResult.Length; i++) { - newRegistryPath += backSlash + split_result[i]; + newRegistryPath += backSlash + splitResult[i]; backSlash = "\\"; } @@ -86,15 +86,16 @@ namespace DerpingDrivers.Util { //rtn = (string)Registry.GetValue(RegistryPath, "CurrentVersion", DefaultValue); - OurKey = OurKey.OpenSubKey(newRegistryPath); - rtn = (string) OurKey.GetValue(Field, DefaultValue); - OurKey.Close(); + ourKey = ourKey.OpenSubKey(newRegistryPath); + rtn = (string) ourKey.GetValue(field, defaultValue); + ourKey.Close(); } } } } catch { + // TODO: argh! } return rtn; @@ -196,10 +197,10 @@ namespace DerpingDrivers.Util try { - var l_System_Info = new SYSTEM_INFO(); - GetNativeSystemInfo(ref l_System_Info); + var systemInfo = new SYSTEM_INFO(); + GetNativeSystemInfo(ref systemInfo); - switch (l_System_Info.uProcessorInfo.wProcessorArchitecture) + switch (systemInfo.uProcessorInfo.wProcessorArchitecture) { case 9: // PROCESSOR_ARCHITECTURE_AMD64 pbits = ProcessorArchitecture.Bit64; @@ -228,7 +229,7 @@ namespace DerpingDrivers.Util #region EDITION - private static string _sEdition; + private static string _edition; /// /// Gets the edition of the operating system running on this computer. @@ -237,8 +238,8 @@ namespace DerpingDrivers.Util { get { - if (_sEdition != null) - return _sEdition; //***** RETURN *****// + if (_edition != null) + return _edition; //***** RETURN *****// var edition = string.Empty; @@ -544,7 +545,7 @@ namespace DerpingDrivers.Util #endregion VERSION 6 } - _sEdition = edition; + _edition = edition; return edition; } } @@ -553,7 +554,7 @@ namespace DerpingDrivers.Util #region NAME - private static string _sName; + private static string _name; /// /// Gets the name of the operating system running on this computer. @@ -562,8 +563,8 @@ namespace DerpingDrivers.Util { get { - if (_sName != null) - return _sName; //***** RETURN *****// + if (_name != null) + return _name; //***** RETURN *****// var name = "unknown"; @@ -751,7 +752,7 @@ namespace DerpingDrivers.Util } } - _sName = name; + _name = name; return name; } }