unit Unit1;
interface usesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, CommDlg;
typeTForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private{ Private declarations }public{ Public declarations }end;
typeTOSVersion = (osUnknown, os95, os95OSR2, os98, os98SE, osNT3, osNT4, os2K, osME, osXP);
varForm1: TForm1;
implementation {$R *.DFM} function GetOS :TOSVersion;
varOS :TOSVersionInfo;
beginZeroMemory(@OS,SizeOf(OS));
OS.dwOSVersionInfoSize:=SizeOf(OS);
GetVersionEx(OS);
Result:=osUnknown;
if OS.dwPlatformId=VER_PLATFORM_WIN32_NT
then begincase OS.dwMajorVersion
of3: Result:=osNT3;
4: Result:=osNT4;
5: Result:=os2K;
end;
if (OS.dwMajorVersion=5)
and (OS.dwMinorVersion=1)
thenResult:=osXP;
end else beginif (OS.dwMajorVersion=4)
and (OS.dwMinorVersion=0)
then beginResult:=os95;
if (Trim(OS.szCSDVersion)='B')
thenResult:=os95OSR2;
end elseif (OS.dwMajorVersion=4)
and (OS.dwMinorVersion=10)
then beginResult:=os98;
if (Trim(OS.szCSDVersion)='A')
thenResult:=os98SE;
end elseif (OS.dwMajorVersion=4)
and (OS.dwMinorVersion=90)
thenResult:=osME;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var os:TosVersion;
osVersion:
string;
beginos:=Getos;
case OS
ofos95, os95OSR2: OSVersion:='Windows 95';
os98: OSVersion:='Windows 98';
os98SE: OSVersion:='Windows 98 第二版';
osME: OSVersion:='Windows Millenium Edition';
osNT3, osNT4: OSVersion:='Windows NT';
os2K: OSVersion:='Windows 2000';
osXP: OSVersion:='Windows XP';
end;
showmessage(osversion);
end;
end.
查看本文来源