winver.pp 1.7 KB

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