winsysut.pp 2.0 KB

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