winver.pp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 by the Free Pascal development team
  4. Windows Version detection functionality.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$mode objfpc}
  12. unit winver;
  13. Interface
  14. Uses Windows;
  15. const
  16. Win32Platform : Integer = 0;
  17. Win32MajorVersion : Integer = 0;
  18. Win32MinorVersion : Integer = 0;
  19. Win32BuildNumber : Integer = 0;
  20. Win32CSDVersion : string = '';
  21. function CheckWin32Version(Major,Minor : Integer ): Boolean;
  22. function CheckWin32Version(Major : Integer): Boolean;
  23. Implementation
  24. uses sysutils;
  25. procedure InitVersion;
  26. var
  27. Info: TOSVersionInfo;
  28. begin
  29. Info.dwOSVersionInfoSize := SizeOf(Info);
  30. if GetVersionEx(Info) then
  31. with Info do
  32. begin
  33. Win32Platform:=dwPlatformId;
  34. Win32MajorVersion:=dwMajorVersion;
  35. Win32MinorVersion:=dwMinorVersion;
  36. if (Win32Platform=VER_PLATFORM_WIN32_WINDOWS) then
  37. Win32BuildNumber:=dwBuildNumber and $FFFF
  38. else
  39. Win32BuildNumber := dwBuildNumber;
  40. Win32CSDVersion := StrPas(szCSDVersion);
  41. end;
  42. end;
  43. function CheckWin32Version(Major : Integer): Boolean;
  44. begin
  45. Result:=CheckWin32Version(Major,0)
  46. end;
  47. function CheckWin32Version(Major,Minor: Integer): Boolean;
  48. begin
  49. Result := (Win32MajorVersion>Major) or
  50. ((Win32MajorVersion=Major) and (Win32MinorVersion>=Minor));
  51. end;
  52. initialization
  53. InitVersion;
  54. end.