public static bool CheckWindowsVersion(int major, int minor, short servicePack) { NativeStructs.OSVERSIONINFOEX osvi = new NativeStructs.OSVERSIONINFOEX(); osvi.dwOSVersionInfoSize = (uint)NativeStructs.OSVERSIONINFOEX.SizeOf; osvi.dwMajorVersion = (uint)major; osvi.dwMinorVersion = (uint)minor; osvi.wServicePackMajor = (ushort)servicePack; ulong mask = 0; mask = NativeMethods.VerSetConditionMask(mask, NativeConstants.VER_MAJORVERSION, NativeConstants.VER_GREATER_EQUAL); mask = NativeMethods.VerSetConditionMask(mask, NativeConstants.VER_MINORVERSION, NativeConstants.VER_GREATER_EQUAL); mask = NativeMethods.VerSetConditionMask(mask, NativeConstants.VER_SERVICEPACKMAJOR, NativeConstants.VER_GREATER_EQUAL); bool result = NativeMethods.VerifyVersionInfo( ref osvi, NativeConstants.VER_MAJORVERSION | NativeConstants.VER_MINORVERSION | NativeConstants.VER_SERVICEPACKMAJOR, mask); return(result); }
internal static extern bool GetVersionEx(ref NativeStructs.OSVERSIONINFOEX lpVersionInfo);
public static bool CheckWindowsVersion(int major, int minor, short servicePack) { NativeStructs.OSVERSIONINFOEX osvi = new NativeStructs.OSVERSIONINFOEX(); osvi.dwOSVersionInfoSize = (uint)NativeStructs.OSVERSIONINFOEX.SizeOf; osvi.dwMajorVersion = (uint)major; osvi.dwMinorVersion = (uint)minor; osvi.wServicePackMajor = (ushort)servicePack; ulong mask = 0; mask = NativeMethods.VerSetConditionMask(mask, NativeConstants.VER_MAJORVERSION, NativeConstants.VER_GREATER_EQUAL); mask = NativeMethods.VerSetConditionMask(mask, NativeConstants.VER_MINORVERSION, NativeConstants.VER_GREATER_EQUAL); mask = NativeMethods.VerSetConditionMask(mask, NativeConstants.VER_SERVICEPACKMAJOR, NativeConstants.VER_GREATER_EQUAL); bool result = NativeMethods.VerifyVersionInfo( ref osvi, NativeConstants.VER_MAJORVERSION | NativeConstants.VER_MINORVERSION | NativeConstants.VER_SERVICEPACKMAJOR, mask); return result; }
internal static extern bool VerifyVersionInfo( ref NativeStructs.OSVERSIONINFOEX lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);