Code clean-up
This commit is contained in:
parent
d5dad5f5c2
commit
5e5a8ae16f
@ -1043,13 +1043,11 @@ 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))
|
|
||||||
{
|
|
||||||
var splitVersion = exactVersion.Split('.');
|
|
||||||
return int.Parse(splitVersion[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Environment.OSVersion.Version.Major;
|
if (string.IsNullOrEmpty(exactVersion)) return Environment.OSVersion.Version.Major;
|
||||||
|
|
||||||
|
var splitVersion = exactVersion.Split('.');
|
||||||
|
return int.Parse(splitVersion[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1067,13 +1065,11 @@ 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))
|
|
||||||
{
|
|
||||||
var splitVersion = exactVersion.Split('.');
|
|
||||||
return int.Parse(splitVersion[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Environment.OSVersion.Version.Minor;
|
if (string.IsNullOrEmpty(exactVersion)) return Environment.OSVersion.Version.Minor;
|
||||||
|
|
||||||
|
var splitVersion = exactVersion.Split('.');
|
||||||
|
return int.Parse(splitVersion[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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");
|
|
||||||
|
|
||||||
if (fnPtr != IntPtr.Zero)
|
var fnPtr = GetProcAddress(handle, "IsWow64Process");
|
||||||
return (IsWow64ProcessDelegate) Marshal.GetDelegateForFunctionPointer(fnPtr,
|
|
||||||
typeof(IsWow64ProcessDelegate));
|
if (fnPtr != IntPtr.Zero)
|
||||||
}
|
return (IsWow64ProcessDelegate) Marshal.GetDelegateForFunctionPointer(fnPtr,
|
||||||
|
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