1
0
This commit is contained in:
Benjamin Höglinger-Stelzer 2018-10-24 20:58:18 +02:00
parent 9517de76c2
commit a251a9ee5a

View File

@ -53,32 +53,32 @@ namespace DerpingDrivers.Util
#region Registry Methods #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 rtn = string.Empty;
var backSlash = ""; var backSlash = string.Empty;
var newRegistryPath = ""; var newRegistryPath = string.Empty;
try try
{ {
RegistryKey OurKey = null; RegistryKey ourKey = null;
var split_result = RegistryPath.Split('\\'); 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; if (splitResult[0] == "HKEY_CLASSES_ROOT") ourKey = Registry.ClassesRoot;
else if (split_result[0] == "HKEY_CURRENT_USER") OurKey = Registry.CurrentUser; else if (splitResult[0] == "HKEY_CURRENT_USER") ourKey = Registry.CurrentUser;
else if (split_result[0] == "HKEY_LOCAL_MACHINE") OurKey = Registry.LocalMachine; else if (splitResult[0] == "HKEY_LOCAL_MACHINE") ourKey = Registry.LocalMachine;
else if (split_result[0] == "HKEY_USERS") OurKey = Registry.Users; else if (splitResult[0] == "HKEY_USERS") ourKey = Registry.Users;
else if (split_result[0] == "HKEY_CURRENT_CONFIG") OurKey = Registry.CurrentConfig; 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 = "\\"; backSlash = "\\";
} }
@ -86,15 +86,16 @@ namespace DerpingDrivers.Util
{ {
//rtn = (string)Registry.GetValue(RegistryPath, "CurrentVersion", DefaultValue); //rtn = (string)Registry.GetValue(RegistryPath, "CurrentVersion", DefaultValue);
OurKey = OurKey.OpenSubKey(newRegistryPath); ourKey = ourKey.OpenSubKey(newRegistryPath);
rtn = (string) OurKey.GetValue(Field, DefaultValue); rtn = (string) ourKey.GetValue(field, defaultValue);
OurKey.Close(); ourKey.Close();
} }
} }
} }
} }
catch catch
{ {
// TODO: argh!
} }
return rtn; return rtn;
@ -196,10 +197,10 @@ namespace DerpingDrivers.Util
try try
{ {
var l_System_Info = new SYSTEM_INFO(); var systemInfo = new SYSTEM_INFO();
GetNativeSystemInfo(ref l_System_Info); GetNativeSystemInfo(ref systemInfo);
switch (l_System_Info.uProcessorInfo.wProcessorArchitecture) switch (systemInfo.uProcessorInfo.wProcessorArchitecture)
{ {
case 9: // PROCESSOR_ARCHITECTURE_AMD64 case 9: // PROCESSOR_ARCHITECTURE_AMD64
pbits = ProcessorArchitecture.Bit64; pbits = ProcessorArchitecture.Bit64;
@ -228,7 +229,7 @@ namespace DerpingDrivers.Util
#region EDITION #region EDITION
private static string _sEdition; private static string _edition;
/// <summary> /// <summary>
/// Gets the edition of the operating system running on this computer. /// Gets the edition of the operating system running on this computer.
@ -237,8 +238,8 @@ namespace DerpingDrivers.Util
{ {
get get
{ {
if (_sEdition != null) if (_edition != null)
return _sEdition; //***** RETURN *****// return _edition; //***** RETURN *****//
var edition = string.Empty; var edition = string.Empty;
@ -544,7 +545,7 @@ namespace DerpingDrivers.Util
#endregion VERSION 6 #endregion VERSION 6
} }
_sEdition = edition; _edition = edition;
return edition; return edition;
} }
} }
@ -553,7 +554,7 @@ namespace DerpingDrivers.Util
#region NAME #region NAME
private static string _sName; private static string _name;
/// <summary> /// <summary>
/// Gets the name of the operating system running on this computer. /// Gets the name of the operating system running on this computer.
@ -562,8 +563,8 @@ namespace DerpingDrivers.Util
{ {
get get
{ {
if (_sName != null) if (_name != null)
return _sName; //***** RETURN *****// return _name; //***** RETURN *****//
var name = "unknown"; var name = "unknown";
@ -751,7 +752,7 @@ namespace DerpingDrivers.Util
} }
} }
_sName = name; _name = name;
return name; return name;
} }
} }