function WindowsBuildFromRegistry: Boolean;
var
s:
string;
begin
Result := false;
with TRegistry.Create(KEY_EXECUTE)
do
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKeyReadOnly(rsRegWinVerInfoKey)
then
try
OSInfo.dwBuildNumber := Cardinal(StrToIntDef(ReadString('
CurrentBuildNumber'),0));
Result := true;
except
end;
CloseKey;
finally
Free;
end;
end;
function GetWinVersion: TWinVersion;
begin
Result := WinUnknown;
case OSInfo.dwPlatformId
of
VER_PLATFORM_WIN32s : Result := Win32s;
VER_PLATFORM_WIN32_WINDOWS :
begin
if (OSInfo.dwMajorVersion = 4)
and (OSInfo.dwMinorVersion = 0)
then Result := Win95;
if (OSInfo.dwMajorVersion = 4)
and (OSInfo.dwMinorVersion = 10)
then Result := Win98;
if (OSInfo.dwMajorVersion = 4)
and (OSInfo.dwMinorVersion = 90)
then Result := WinME;
end;
{-VER_PLATFORM_WIN32_WINDOWS-}
VER_PLATFORM_WIN32_NT:
begin
if (OSInfo.dwMajorVersion = 4)
and (OSInfo.dwMinorVersion = 0)
then Result :=
WinNT;
if (OSInfo.dwMajorVersion = 5)
and (OSInfo.dwMinorVersion = 0)
then Result := Win2000;
if (OSInfo.dwMajorVersion = 5)
and (OSInfo.dwMinorVersion = 1)
then Result := WinXP;
if (OSInfo.dwMajorVersion = 5)
and (OSInfo.dwMinorVersion = 2)
then
begin
if GetSystemMetrics(SM_SERVERR2) <> 0
then Result := Win2003R2
else
if (OSInfo.wProductType = VER_NT_WORKSTATION)
then Result := WinXP64
else
if OSInfo.wSuiteMask = VER_SUITE_WH_SERVER
then Result := WinHomeSrv
else Result := Win2003;
end;
if (OSInfo.dwMajorVersion = 6)
and (OSInfo.dwMinorVersion = 0)
then
begin
if (OSInfo.wProductType = VER_NT_WORKSTATION)
then Result := WinVista
else Result := Win2008;
end;
if (OSInfo.dwMajorVersion = 6)
and (OSInfo.dwMinorVersion = 1)
then
begin
if (OSInfo.wProductType = VER_NT_WORKSTATION)
then Result := Win7
else Result := Win2008R2;
end;
if (OSInfo.dwMajorVersion = 6)
and (OSInfo.dwMinorVersion = 2)
then
begin
if WindowsBuildFromRegistry
then begin
case OSInfo.dwBuildNumber
of
9200 :
case OSInfo.wProductType
of
VER_NT_WORKSTATION : Result := Win8;
VER_NT_DOMAIN_CONTROLLER : Result := Win2012;
VER_NT_SERVER : Result := Win2012;
end;
9600 :
case OSInfo.wProductType
of
VER_NT_WORKSTATION : Result := Win81;
VER_NT_DOMAIN_CONTROLLER : Result := Win2012R2;
VER_NT_SERVER : Result := Win2012R2;
end;
9841..9880 : Result := Windows10;
// Die Preview ist aktuell bei Build 9879
end;
end;
end;
end;
{-VER_PLATFORM_WIN32_NT-}
end;
end;