Removed redundant helper method
This commit is contained in:
parent
5e5a8ae16f
commit
dfed4cb19d
@ -68,58 +68,6 @@ namespace DerpingDrivers.Util
|
||||
|
||||
#endregion
|
||||
|
||||
#region Registry Methods
|
||||
|
||||
private static string RegistryRead(string registryPath, string field, string defaultValue)
|
||||
{
|
||||
var rtn = string.Empty;
|
||||
var backSlash = string.Empty;
|
||||
var newRegistryPath = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
RegistryKey ourKey = null;
|
||||
var splitResult = registryPath.Split('\\');
|
||||
|
||||
if (splitResult.Length > 0)
|
||||
{
|
||||
splitResult[0] = splitResult[0].ToUpper(); // Make the first entry uppercase...
|
||||
|
||||
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)
|
||||
{
|
||||
for (var i = 1; i < splitResult.Length; i++)
|
||||
{
|
||||
newRegistryPath += backSlash + splitResult[i];
|
||||
backSlash = "\\";
|
||||
}
|
||||
|
||||
if (newRegistryPath != "")
|
||||
{
|
||||
//rtn = (string)Registry.GetValue(RegistryPath, "CurrentVersion", DefaultValue);
|
||||
|
||||
ourKey = ourKey.OpenSubKey(newRegistryPath);
|
||||
rtn = (string) ourKey.GetValue(field, defaultValue);
|
||||
ourKey.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: argh!
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
#endregion Registry Methods
|
||||
|
||||
#region DELEGATE DECLARATION
|
||||
|
||||
private delegate bool IsWow64ProcessDelegate([In] IntPtr handle, [Out] out bool isWow64Process);
|
||||
@ -606,8 +554,8 @@ namespace DerpingDrivers.Util
|
||||
// For applications that have been manifested for Windows 8.1 & Windows 10. Applications not manifested for 8.1 or 10 will return the Windows 8 OS version value (6.2).
|
||||
// By reading the registry, we'll get the exact version - meaning we can even compare against Win 8 and Win 8.1.
|
||||
var exactVersion =
|
||||
RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
||||
"CurrentVersion", "");
|
||||
Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
||||
"CurrentVersion", null) as string;
|
||||
if (!string.IsNullOrEmpty(exactVersion))
|
||||
{
|
||||
var splitResult = exactVersion.Split('.');
|
||||
@ -1004,7 +952,7 @@ namespace DerpingDrivers.Util
|
||||
/// Gets the build version number of the operating system running on this computer.
|
||||
/// </summary>
|
||||
public static int BuildVersion =>
|
||||
int.Parse(RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
||||
int.Parse((string) Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
||||
"CurrentBuildNumber", "0"));
|
||||
|
||||
#endregion BUILD
|
||||
@ -1041,8 +989,8 @@ namespace DerpingDrivers.Util
|
||||
get
|
||||
{
|
||||
if (IsWindows10) return 10;
|
||||
var exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
||||
"CurrentVersion", "");
|
||||
var exactVersion = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
||||
"CurrentVersion", null) as string;
|
||||
|
||||
if (string.IsNullOrEmpty(exactVersion)) return Environment.OSVersion.Version.Major;
|
||||
|
||||
@ -1063,8 +1011,8 @@ namespace DerpingDrivers.Util
|
||||
get
|
||||
{
|
||||
if (IsWindows10) return 0;
|
||||
var exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
||||
"CurrentVersion", "");
|
||||
var exactVersion = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
||||
"CurrentVersion", null) as string;
|
||||
|
||||
if (string.IsNullOrEmpty(exactVersion)) return Environment.OSVersion.Version.Minor;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user