1{ 2 This file is part of the Free Pascal run time library. 3 Copyright (c) 2003 by the Free Pascal development team 4 5 Windows specific versions of Borland SysUtils routines. 6 7 See the file COPYING.FPC, included in this distribution, 8 for details about the copyright. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 14 **********************************************************************} 15{$mode objfpc} 16unit WinSysUt; 17 18Interface 19 20Uses Windows,SysUtils; 21 22const 23 Win32Platform : Integer = 0; 24 Win32MajorVersion : Integer = 0; 25 Win32MinorVersion : Integer = 0; 26 Win32BuildNumber : Integer = 0; 27 28 Win32CSDVersion : string = ''; 29 30function CheckWin32Version(Major,Minor : Integer ): Boolean; 31function CheckWin32Version(Major : Integer): Boolean; 32Function Win32Check(RetVal: BOOL): BOOL; 33Procedure RaiseLastWin32Error; 34 35Implementation 36 37procedure RaiseLastWin32Error; 38 39begin 40 RaiseLastOSError; 41end; 42 43Function Win32Check(RetVal: BOOL): BOOL; 44 45begin 46 if Not RetVal then 47 RaiseLastOSError; 48 Result := RetVal; 49end; 50 51procedure InitVersion; 52 53var 54 Info: TOSVersionInfo; 55 56begin 57 Info.dwOSVersionInfoSize := SizeOf(Info); 58 if GetVersionEx(Info) then 59 with Info do 60 begin 61 Win32Platform:=dwPlatformId; 62 Win32MajorVersion:=dwMajorVersion; 63 Win32MinorVersion:=dwMinorVersion; 64 if (Win32Platform=VER_PLATFORM_WIN32_WINDOWS) then 65 Win32BuildNumber:=dwBuildNumber and $FFFF 66 else 67 Win32BuildNumber := dwBuildNumber; 68 Win32CSDVersion := StrPas(szCSDVersion); 69 end; 70end; 71 72function CheckWin32Version(Major : Integer): Boolean; 73 74begin 75 Result:=CheckWin32Version(Major,0) 76end; 77 78function CheckWin32Version(Major,Minor: Integer): Boolean; 79 80begin 81 Result := (Win32MajorVersion>Major) or 82 ((Win32MajorVersion=Major) and (Win32MinorVersion>=Minor)); 83end; 84 85Initialization 86 InitVersion; 87end. 88