function TForm1.GetOperatingSystem(): String;
var
osVerInfo: TOSVersionInfo;
majorVer, minorVer: Integer;
begin
osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if GetVersionEx(osVerInfo) then
begin
majorVer := osVerInfo.dwMajorVersion;
minorVer := osVerInfo.dwMinorVersion;
case osVerInfo.dwPlatformId of
// Windows NT/2000
VER_PLATFORM_WIN32_NT:
begin
if majorVer <= 4 then
Result := '
WinNT'
else if (majorVer = 5) and (minorVer = 0) then
Result := 'Win2000'
else if (majorVer = 5) and (minorVer = 1) then
Result := 'WinXP'
else if (majorVer = 6) and (minorVer = 0) then
Result := 'WinVista'
else if (majorVer = 6) and (minorVer = 1) then
Result := 'Win7'
else
Result := 'Unknown';
end;
// Windows 9x/ME
VER_PLATFORM_WIN32_WINDOWS:
begin
if (majorVer = 4) and (minorVer = 0) then
Result := 'Win95'
else if (majorVer = 4) and (minorVer = 10) then
begin
if osVerInfo.szCSDVersion[1] = 'A' then
Result := 'Win98SE'
else
Result := 'Win98';
end
else if (majorVer = 4) and (minorVer = 90) then
Result := 'WinME'
else
Result := 'Unknown';
end;
else
Result := 'Unknown';
end;
end
else
Result := 'Unknown';
end;