代碼: 選擇全部
procedure Tform1.formCreate(Sender: TObject);
Var
s:string;
osvi:TOSVERSIONINFO ;
begin
osvi.dwOSVersionInfoSize := sizeof(OSVERSIONINFO);
if GetVersionEx(osvi)=FALSE then
begin
exit;
end;
if osvi.dwPlatformId=VER_PLATform_WIN32_NT then
begin
if ( osvi.dwMajorVersion = 5) AND (osvi.dwMinorVersion = 2 ) then
s:='Microsoft Windows Server 2003 family,'
else
if ( osvi.dwMajorVersion = 5) AND (osvi.dwMinorVersion = 1 ) then
s:='Microsoft Windows XP '
else
if ( osvi.dwMajorVersion = 5) AND (osvi.dwMinorVersion = 0 ) then
s:='Microsoft Windows 2000 '
else
if osvi.dwMajorVersion <= 4 then
s:='Microsoft Windows NT ';
end
else
if osvi.dwPlatformId=VER_PLATform_WIN32_WINDOWS then
begin
if (osvi.dwMajorVersion = 4) and (osvi.dwMinorVersion = 0) then
begin
s:='Microsoft Windows 95 ';
if ( osvi.szCSDVersion[1] = 'C') or (osvi.szCSDVersion[1] = 'B' ) then
s:=s+' OSR2 ';
end
else
if (osvi.dwMajorVersion = 4) and ( osvi.dwMinorVersion = 10) then
begin
s:='Microsoft Windows 98 ';
if osvi.szCSDVersion[1] = 'A' then
s:=s+'SE ';
end
else
if (osvi.dwMajorVersion = 4) and (osvi.dwMinorVersion = 90) then
s:=s+'Microsoft Windows Millennium Edition';
end
else
if osvi.dwPlatformId=VER_PLATform_WIN32s then
begin
s:= 'Microsoft Win32s';
end;
Showmessage(s);
end;