Guest User

Untitled

a guest
Oct 18th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public static class VersionHelpers
  2. {
  3. public static bool IsWindows7OrGreater()
  4. {
  5. var winver = new RtlOsVersionInfo();
  6. winver.OsVersionInfoSize = Marshal.SizeOf(winver);
  7. RtlGetVersion(ref winver);
  8.  
  9. return
  10. (winver.MajorVersion > 6 ||
  11. (winver.MajorVersion == 6 & winver.MinorVersion >= 1));
  12. }
  13.  
  14. [DllImport("ntdll.dll")]
  15. private static extern int RtlGetVersion(ref RtlOsVersionInfo versionInformation);
  16.  
  17. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
  18. private struct RtlOsVersionInfo
  19. {
  20. public int OsVersionInfoSize;
  21. public int MajorVersion;
  22. public int MinorVersion;
  23. public int BuildNumber;
  24. public int PlatformId;
  25.  
  26. [MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
  27. public string CsdVersion;
  28. }
  29. }
Add Comment
Please, Sign In to add comment