winsysut.pp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 specific versions of Borland SysUtils routines.
  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. {$IFNDEF FPC_DOTTEDUNITS}
  13. unit WinSysUt;
  14. {$ENDIF FPC_DOTTEDUNITS}
  15. Interface
  16. {$IFDEF FPC_DOTTEDUNITS}
  17. Uses WinApi.Windows,System.SysUtils;
  18. {$ELSE FPC_DOTTEDUNITS}
  19. Uses Windows,SysUtils;
  20. {$ENDIF FPC_DOTTEDUNITS}
  21. const
  22. Win32Platform : Integer = 0;
  23. Win32MajorVersion : Integer = 0;
  24. Win32MinorVersion : Integer = 0;
  25. Win32BuildNumber : Integer = 0;
  26. Win32CSDVersion : string = '';
  27. function CheckWin32Version(Major,Minor : Integer ): Boolean;
  28. function CheckWin32Version(Major : Integer): Boolean;
  29. Function Win32Check(RetVal: BOOL): BOOL;
  30. Procedure RaiseLastWin32Error;
  31. Implementation
  32. procedure RaiseLastWin32Error;
  33. begin
  34. RaiseLastOSError;
  35. end;
  36. Function Win32Check(RetVal: BOOL): BOOL;
  37. begin
  38. if Not RetVal then
  39. RaiseLastOSError;
  40. Result := RetVal;
  41. end;
  42. procedure InitVersion;
  43. var
  44. Info: TOSVersionInfo;
  45. begin
  46. Info.dwOSVersionInfoSize := SizeOf(Info);
  47. if GetVersionEx(Info) then
  48. with Info do
  49. begin
  50. Win32Platform:=dwPlatformId;
  51. Win32MajorVersion:=dwMajorVersion;
  52. Win32MinorVersion:=dwMinorVersion;
  53. if (Win32Platform=VER_PLATFORM_WIN32_WINDOWS) then
  54. Win32BuildNumber:=dwBuildNumber and $FFFF
  55. else
  56. Win32BuildNumber := dwBuildNumber;
  57. Win32CSDVersion := StrPas(szCSDVersion);
  58. end;
  59. end;
  60. function CheckWin32Version(Major : Integer): Boolean;
  61. begin
  62. Result:=CheckWin32Version(Major,0)
  63. end;
  64. function CheckWin32Version(Major,Minor: Integer): Boolean;
  65. begin
  66. Result := (Win32MajorVersion>Major) or
  67. ((Win32MajorVersion=Major) and (Win32MinorVersion>=Minor));
  68. end;
  69. Initialization
  70. InitVersion;
  71. end.