unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>const strOsType: array[0..7] of string=('osUnknown','osWin95','osWin98','osWin98se','osWinme','osWinnt4','osWin2k','osWinxp');<br>type OSType=(osUnknown,osWin95,osWin98,osWin98se,osWinme,osWinnt4,osWin2k,osWinxp);<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>Function GetOSVersion : OSType;<br>Var<br> osVerInfo : TOSVersionInfo;<br> majorVer, minorVer : Integer;<br>Begin<br><br> //Result := osUnknown;<br> osVerInfo.dwOSVersionInfoSize := SizeOf( TOSVersionInfo );<br> If ( GetVersionEx( osVerInfo ) ) Then <br> Begin<br> majorVer := osVerInfo.dwMajorVersion;<br> minorVer := osVerInfo.dwMinorVersion;<br> Case ( osVerInfo.dwPlatformId ) Of<br> VER_PLATFORM_WIN32_NT : { Windows NT/2000 }<br> Begin<br> If ( majorVer <= 4 ) Then<br> Result := osWinnt4<br> Else<br> If ( ( majorVer = 5 ) And ( minorVer= 0 ) ) Then<br> Result := osWin2k<br> Else<br> If ( ( majorVer = 5) And ( minorVer = 1 ) ) Then<br> Result := osWinxp<br> Else<br> Result := OsUnknown;<br> End;<br> VER_PLATFORM_WIN32_WINDOWS : { Windows 9x/ME }<br> Begin<br><br> If ( ( majorVer = 4 ) And ( minorVer = 0 ) ) Then<br> Result := osWin95<br> Else If ( ( majorVer = 4 ) And ( minorVer = 10 ) ) Then <br> Begin<br> If ( osVerInfo.szCSDVersion[ 1 ] = 'A' ) Then<br> Result := osWin98se<br> Else<br> Result := osWin98;<br> End <br> Else If ( ( majorVer = 4) And ( minorVer = 90 ) ) Then<br> Result := OsWinME<br> Else<br> Result := OsUnknown;<br><br> End;<br> Else<br> Result := OsUnknown;<br> End; //end of case<br> End Else<br> Result := OsUnknown;<br><br>End;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> ShowMessage(strOsType[integer(GetOSVersion)]);<br>end;<br><br>end.<br>