I am using this code to detect the WindowsVersion on a PC.
function GetOS: string;
var
osVerInfo: TOSVersionInfo;
majorVer, minorVer: Integer;
begin
Result := 'Unknown';
osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
if GetVersionEx(osVerInfo) then
begin
majorVer := osVerInfo.dwMajorVersion;
minorVer := osVerInfo.dwMinorVersion;
case osVerInfo.dwPlatformId of
VER_PLATFORM_WIN32_NT: {Mirosoft Windows NT/2000 }
begin
if majorVer <= 4 then
Result := 'Win NT'
else if (majorVer = 5) and (minorVer = 0) then
Result := 'Win 2k'
else if (majorVer = 5) and (minorVer = 1) then
Result := 'Win XP'
else if (majorVer = 6) and (minorVer = 0) then
Result := 'Win Vista'
else if (majorVer = 6) and (minorVer = 1) then
Result := 'Win 7'
else if (majorVer = 6) and (minorVer = 2) then
Result := 'Win 8'
end;
VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME }
begin
if (majorVer = 4) and (minorVer = 0) then
Result := 'Win 95'
else if (majorVer = 4) and (minorVer = 10) then
begin
if osVerInfo.szCSDVersion[1] = 'A' then
Result := 'Win 98SE'
else
Result := 'Win 98';
end
else if (majorVer = 4) and (minorVer = 90) then
Result := 'Win ME'
end;
end;
end;
end;
For some reason it says that Windows8 Consumer Preview Build 8250 (32bit) is Windows XP - Major Version 5. I checked and it's supposed to be Version 6.2 (according to notepad.exe on windows8) Is this a bug or is something wrong? btw. my Windows 8 is up2date.
Any Ideas?
EDIT: ScreenShot
osVerInfo
and trace through it to see how you end up with that result. That'll give you an idea of what's going on. – SadismGetVersionEx
returns 6.2, so has @AntonioBakula says probably your are executing you app in XP compatibility mode. – Salutary