private static bool IsWindowsVersionOrGreater(uint majorVersion, uint minorVersion, ushort servicePackMajor) { var osvi = new NativeStructs.RTL_OSVERSIONINFOEXW(0); ulong conditionMask = Kernel32.VerSetConditionMask ( Kernel32.VerSetConditionMask ( Kernel32.VerSetConditionMask ( 0, NativeConstants.VER_MAJORVERSION, NativeConstants.VER_GREATER_EQUAL ), NativeConstants.VER_MINORVERSION, NativeConstants.VER_GREATER_EQUAL ), NativeConstants.VER_SERVICEPACKMAJOR, NativeConstants.VER_GREATER_EQUAL ); osvi.dwMajorVersion = majorVersion; osvi.dwMinorVersion = minorVersion; osvi.wServicePackMajor = servicePackMajor; return(NtDll.RtlVerifyVersionInfo(ref osvi, NativeConstants.VER_MAJORVERSION | NativeConstants.VER_MINORVERSION | NativeConstants.VER_SERVICEPACKMAJOR, conditionMask) == NativeConstants.STATUS_SUCCESS); }
public static bool IsWindowsServer() { var osvi = new NativeStructs.RTL_OSVERSIONINFOEXW(0); osvi.wProductType = NativeConstants.VER_NT_WORKSTATION; ulong conditionMask = Kernel32.VerSetConditionMask(0, NativeConstants.VER_PRODUCT_TYPE, NativeConstants.VER_EQUAL); var result = NtDll.RtlVerifyVersionInfo(ref osvi, NativeConstants.VER_PRODUCT_TYPE, conditionMask); bool clientOS = (result == NativeConstants.STATUS_SUCCESS); return(!clientOS); }