unit UWinVer;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var dwVersion: DWord;
    dwWindowsMajorVersion,dwWindowsMinorVersion, dwBuild: Word;
    S: string;
begin
 dwVersion := GetVersion;
 dwWindowsMajorVersion :=  Byte(Word(dwVersion));
 dwWindowsMinorVersion :=  HiByte(Word(dwVersion));
 if (dwVersion < $80000000)
 then begin
  S := 'Windows NT';
  dwBuild := HiWord(dwVersion);
 end
 else if (dwWindowsMajorVersion < 4)
  then begin
   S := 'Win32s';
   dwBuild := HiWord(dwVersion) and $7FFFFFFF;
  end
  else begin
   S := 'Windows 9.x';
   dwBuild :=  0;
  end;
 S := S + ', версия ' + IntToStr(dwWindowsMajorVersion) + '.' +
       IntToStr(dwWindowsMinorVersion) + ', модификация ' +
       IntToStr(dwBuild);
 Edit1.Text := S;
end;

procedure TForm1.Button2Click(Sender: TObject);
var OSVer: TOSVersionInfo;
    S: string;
begin
 OSVer.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
 GetVersionEx(OSVer);
 case OSVer.dwPlatformId of
  VER_PLATFORM_WIN32s: S := 'Windows 3.1';
  VER_PLATFORM_WIN32_WINDOWS : S := 'Windows 9.x';
  VER_PLATFORM_WIN32_NT: S := 'Windows NT';
 end;
 with OSVer do
  if S = 'Windows NT'
   then S := S + ', версия ' + IntToStr(dwMajorVersion) + '.' +
       IntToStr(dwMinorVersion) + ', модификация ' +
       IntToStr(dwBuildNumber)
  else if S = 'Windows 9.x'
   then S := S + ', ' + IntToStr(Word(dwBuildNumber)) + ' версия ' + IntToStr(dwMajorVersion) + '.' +
             IntToStr(dwMinorVersion);
 Edit1.Text := S;
end;

function IsNT: boolean;
begin
 Result := GetVersion < $80000000;
end;


procedure TForm1.Button3Click(Sender: TObject);
begin
 if IsNT
  then Edit1.Text := 'Windows NT\2000\ME\XP'
  else Edit1.Text := 'Windows 9.x';
end;

end.
