winsysut.pp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. unit WinSysUt;
  13. Interface
  14. Uses Windows,SysUtils;
  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. Function Win32Check(RetVal: BOOL): BOOL;
  24. Procedure RaiseLastWin32Error;
  25. Implementation
  26. procedure RaiseLastWin32Error;
  27. begin
  28. RaiseLastOSError;
  29. end;
  30. Function Win32Check(RetVal: BOOL): BOOL;
  31. begin
  32. if Not RetVal then
  33. RaiseLastOSError;
  34. Result := RetVal;
  35. end;
  36. procedure InitVersion;
  37. var
  38. Info: TOSVersionInfo;
  39. begin
  40. Info.dwOSVersionInfoSize := SizeOf(Info);
  41. if GetVersionEx(Info) then
  42. with Info do
  43. begin
  44. Win32Platform:=dwPlatformId;
  45. Win32MajorVersion:=dwMajorVersion;
  46. Win32MinorVersion:=dwMinorVersion;
  47. if (Win32Platform=VER_PLATFORM_WIN32_WINDOWS) then
  48. Win32BuildNumber:=dwBuildNumber and $FFFF
  49. else
  50. Win32BuildNumber := dwBuildNumber;
  51. Win32CSDVersion := StrPas(szCSDVersion);
  52. end;
  53. end;
  54. function CheckWin32Version(Major : Integer): Boolean;
  55. begin
  56. Result:=CheckWin32Version(Major,0)
  57. end;
  58. function CheckWin32Version(Major,Minor: Integer): Boolean;
  59. begin
  60. Result := (Win32MajorVersion>Major) or
  61. ((Win32MajorVersion=Major) and (Win32MinorVersion>=Minor));
  62. end;
  63. Initialization
  64. InitVersion;
  65. end.