Code clean-up
This commit is contained in:
parent
d5dad5f5c2
commit
5e5a8ae16f
@ -1043,14 +1043,12 @@ namespace DerpingDrivers.Util
|
|||||||
if (IsWindows10) return 10;
|
if (IsWindows10) return 10;
|
||||||
var exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
var exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
||||||
"CurrentVersion", "");
|
"CurrentVersion", "");
|
||||||
if (!string.IsNullOrEmpty(exactVersion))
|
|
||||||
{
|
if (string.IsNullOrEmpty(exactVersion)) return Environment.OSVersion.Version.Major;
|
||||||
|
|
||||||
var splitVersion = exactVersion.Split('.');
|
var splitVersion = exactVersion.Split('.');
|
||||||
return int.Parse(splitVersion[0]);
|
return int.Parse(splitVersion[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Environment.OSVersion.Version.Major;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion MAJOR
|
#endregion MAJOR
|
||||||
@ -1067,14 +1065,12 @@ namespace DerpingDrivers.Util
|
|||||||
if (IsWindows10) return 0;
|
if (IsWindows10) return 0;
|
||||||
var exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
var exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion",
|
||||||
"CurrentVersion", "");
|
"CurrentVersion", "");
|
||||||
if (!string.IsNullOrEmpty(exactVersion))
|
|
||||||
{
|
if (string.IsNullOrEmpty(exactVersion)) return Environment.OSVersion.Version.Minor;
|
||||||
|
|
||||||
var splitVersion = exactVersion.Split('.');
|
var splitVersion = exactVersion.Split('.');
|
||||||
return int.Parse(splitVersion[1]);
|
return int.Parse(splitVersion[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Environment.OSVersion.Version.Minor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion MINOR
|
#endregion MINOR
|
||||||
@ -1084,14 +1080,7 @@ namespace DerpingDrivers.Util
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the revision version number of the operating system running on this computer.
|
/// Gets the revision version number of the operating system running on this computer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int RevisionVersion
|
public static int RevisionVersion => IsWindows10 ? 0 : Environment.OSVersion.Version.Revision;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (IsWindows10) return 0;
|
|
||||||
return Environment.OSVersion.Version.Revision;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion REVISION
|
#endregion REVISION
|
||||||
|
|
||||||
@ -1103,14 +1092,13 @@ namespace DerpingDrivers.Util
|
|||||||
{
|
{
|
||||||
var handle = LoadLibrary("kernel32");
|
var handle = LoadLibrary("kernel32");
|
||||||
|
|
||||||
if (handle != IntPtr.Zero)
|
if (handle == IntPtr.Zero) return null;
|
||||||
{
|
|
||||||
var fnPtr = GetProcAddress(handle, "IsWow64Process");
|
var fnPtr = GetProcAddress(handle, "IsWow64Process");
|
||||||
|
|
||||||
if (fnPtr != IntPtr.Zero)
|
if (fnPtr != IntPtr.Zero)
|
||||||
return (IsWow64ProcessDelegate) Marshal.GetDelegateForFunctionPointer(fnPtr,
|
return (IsWow64ProcessDelegate) Marshal.GetDelegateForFunctionPointer(fnPtr,
|
||||||
typeof(IsWow64ProcessDelegate));
|
typeof(IsWow64ProcessDelegate));
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -1121,12 +1109,9 @@ namespace DerpingDrivers.Util
|
|||||||
|
|
||||||
if (fnDelegate == null) return false;
|
if (fnDelegate == null) return false;
|
||||||
|
|
||||||
bool isWow64;
|
var retVal = fnDelegate.Invoke(Process.GetCurrentProcess().Handle, out var isWow64);
|
||||||
var retVal = fnDelegate.Invoke(Process.GetCurrentProcess().Handle, out isWow64);
|
|
||||||
|
|
||||||
if (retVal == false) return false;
|
return retVal && isWow64;
|
||||||
|
|
||||||
return isWow64;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion 64 BIT OS DETECTION
|
#endregion 64 BIT OS DETECTION
|
||||||
|
Loading…
Reference in New Issue
Block a user