Remove calls to `GetVersionEx`
With fix 0ca32249c1
and #2095 resolved, `GetVersionEx` is no longer required.
This commit is contained in:
Родитель
a27eaba69b
Коммит
b5465ffee7
|
@ -125,8 +125,7 @@ namespace Microsoft.Toolkit.Win32.UI.Controls.Interop
|
|||
[SecurityCritical]
|
||||
private static bool IsServer()
|
||||
{
|
||||
// RtlGetVersion does not return ProductType
|
||||
var versionInfo = NativeMethods.GetVersionEx();
|
||||
var versionInfo = NativeMethods.RtlGetVersion();
|
||||
return versionInfo.ProductType == ProductType.VER_NT_DOMAIN_CONTROLLER
|
||||
|| versionInfo.ProductType == ProductType.VER_NT_SERVER;
|
||||
}
|
||||
|
@ -167,7 +166,7 @@ namespace Microsoft.Toolkit.Win32.UI.Controls.Interop
|
|||
throw new ArgumentException(DesignerUI.E_UNRECOGNIZED_OS, nameof(version));
|
||||
}
|
||||
|
||||
// After 8.1 apps without manifest or are not manifested for 8.1/10 return 6.2.
|
||||
// After 8.1 apps without manifest or are not manifested for 8.1/10 return 6.2 when using GetVersionEx.
|
||||
// Need to use RtlGetVersion to get correct major/minor/build
|
||||
var os = NativeMethods.RtlGetVersion();
|
||||
|
||||
|
|
|
@ -59,29 +59,6 @@ namespace Microsoft.Toolkit.Win32.UI.Controls.Interop.Win32
|
|||
[DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
|
||||
public static extern bool IsChild(HandleRef parent, HandleRef child);
|
||||
|
||||
[SecurityCritical]
|
||||
[DllImport(ExternDll.Kernel32, SetLastError = true, EntryPoint = "GetVersionExW", CharSet = CharSet.Unicode)]
|
||||
private static extern bool _GetVersionExW(ref OSVERSIONINFOEX osVersionInfo);
|
||||
|
||||
// With the release of Windows 8.1, the behavior of the GetVersionEx API has changed the
|
||||
// value it will return for the OS version. The value returned now depends on how the application
|
||||
// is manifested.
|
||||
//
|
||||
// Applications not manifested for for Windows 8.1 or Windows 10 will return the Windows 8 OS
|
||||
// version value of 6.2. Once an application is manifested for a given OS version, GetVersionEx
|
||||
// will always return the version that the application is manifested for in future releases.
|
||||
[SecurityCritical]
|
||||
public static OSVERSIONINFOEX GetVersionEx()
|
||||
{
|
||||
var osVersionInfo = new OSVERSIONINFOEX { OSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX)) };
|
||||
if (!_GetVersionExW(ref osVersionInfo))
|
||||
{
|
||||
HRESULT.ThrowLastError();
|
||||
}
|
||||
|
||||
return osVersionInfo;
|
||||
}
|
||||
|
||||
[SecurityCritical]
|
||||
[DllImport(ExternDll.Ntdll, SetLastError = true, EntryPoint = "RtlGetVersion")]
|
||||
private static extern bool _RtlGetVersion(ref OSVERSIONINFOEX versionInfo);
|
||||
|
|
Загрузка…
Ссылка в новой задаче