private static bool GetIsWindows8OrAbove() { bool isWindows8OrAbove; unsafe { ulong conditionMask = Win32Native.VerSetConditionMask(0, Win32Native.VER_MAJORVERSION, Win32Native.VER_GREATER_EQUAL); conditionMask = Win32Native.VerSetConditionMask(conditionMask, Win32Native.VER_MINORVERSION, Win32Native.VER_GREATER_EQUAL); conditionMask = Win32Native.VerSetConditionMask(conditionMask, Win32Native.VER_SERVICEPACKMAJOR, Win32Native.VER_GREATER_EQUAL); conditionMask = Win32Native.VerSetConditionMask(conditionMask, Win32Native.VER_SERVICEPACKMINOR, Win32Native.VER_GREATER_EQUAL); // Windows 8 version is 6.2 var version = new Win32Native.OSVERSIONINFOEX(); version.dwOSVersionInfoSize = sizeof(Win32Native.OSVERSIONINFOEX); version.dwMajorVersion = 6; version.dwMinorVersion = 2; version.wServicePackMajor = 0; version.wServicePackMinor = 0; isWindows8OrAbove = Win32Native.VerifyVersionInfoW(ref version, Win32Native.VER_MAJORVERSION | Win32Native.VER_MINORVERSION | Win32Native.VER_SERVICEPACKMAJOR | Win32Native.VER_SERVICEPACKMINOR, conditionMask); } return(isWindows8OrAbove); }
static Win32() { Win32Native.OSVERSIONINFO osVer1 = new Win32Native.OSVERSIONINFO(); if (!Environment.GetVersion(osVer1)) { throw new SystemException(Environment.GetResourceString("InvalidOperation_GetVersion")); } if (osVer1.MajorVersion > 5 || osVer1.MinorVersion > 0) { System.Security.Principal.Win32._LsaLookupNames2Supported = true; System.Security.Principal.Win32._WellKnownSidApisSupported = true; } else { System.Security.Principal.Win32._LsaLookupNames2Supported = false; Win32Native.OSVERSIONINFOEX osVer2 = new Win32Native.OSVERSIONINFOEX(); if (!Environment.GetVersionEx(osVer2)) { throw new SystemException(Environment.GetResourceString("InvalidOperation_GetVersion")); } if ((int)osVer2.ServicePackMajor < 3) { System.Security.Principal.Win32._WellKnownSidApisSupported = false; } else { System.Security.Principal.Win32._WellKnownSidApisSupported = true; } } }
static Win32() { Win32Native.OSVERSIONINFO osversioninfo = new Win32Native.OSVERSIONINFO(); if (!Environment.GetVersion(osversioninfo)) { throw new SystemException(Environment.GetResourceString("InvalidOperation_GetVersion")); } if (osversioninfo.MajorVersion > 5 || osversioninfo.MinorVersion > 0) { Win32._LsaLookupNames2Supported = true; Win32._WellKnownSidApisSupported = true; return; } Win32._LsaLookupNames2Supported = false; Win32Native.OSVERSIONINFOEX osversioninfoex = new Win32Native.OSVERSIONINFOEX(); if (!Environment.GetVersionEx(osversioninfoex)) { throw new SystemException(Environment.GetResourceString("InvalidOperation_GetVersion")); } if (osversioninfoex.ServicePackMajor < 3) { Win32._WellKnownSidApisSupported = false; return; } Win32._WellKnownSidApisSupported = true; }
[System.Security.SecuritySafeCritical] // auto-generated static Win32() { Win32Native.OSVERSIONINFO osvi = new Win32Native.OSVERSIONINFO(); bool r = Environment.GetVersion(osvi); if (!r) { Contract.Assert(r, "OSVersion native call failed."); throw new SystemException(Environment.GetResourceString("InvalidOperation_GetVersion")); } if (osvi.MajorVersion > 5 || osvi.MinorVersion > 0) // Windows XP/2003 and above { // // LsaLookupNames2 supported only on XP and Windows 2003 and above // _LsaLookupNames2Supported = true; _WellKnownSidApisSupported = true; } else { // Win2000 _LsaLookupNames2Supported = false; // // WellKnownSid apis are only supported on Windows 2000 SP3 and above // (so we need sp info) // Win32Native.OSVERSIONINFOEX osviex = new Win32Native.OSVERSIONINFOEX(); r = Environment.GetVersionEx(osviex); if (!r) { Contract.Assert(r, "OSVersion native call failed"); throw new SystemException(Environment.GetResourceString("InvalidOperation_GetVersion")); } if (osviex.ServicePackMajor < 3) { _WellKnownSidApisSupported = false; } else { _WellKnownSidApisSupported = true; } } }
internal static extern bool GetVersionEx(Win32Native.OSVERSIONINFOEX osVer);