This function is the same as GetWindowsVersion() but returns a detailed string version of the OS.
functionGetWindowsVersionStr: string; var VerInfo: TOSVersionInfo; ResultStr: string; begin ResultStr := ''; VerInfo.dwOSVersionInfoSize := SizeOf(VerInfo); GetVersionEx(VerInfo); with VerInfo do begin case dwPlatformID of VER_PLATFORM_WIN32S: ResultStr := ResultStr + 'Windows 3.1x running Win32s '; VER_PLATFORM_WIN32_WINDOWS: begin if IntToStr(dwMajorVersion) + '.' + IntToStr(dwMinorVersion) < '4.10' then ResultStr := ResultStr + 'Windows 95 ' + szCSDVersion + ' ' else ResultStr := ResultStr + 'Windows 98 ' + szCSDVersion + ' '; end; VER_PLATFORM_WIN32_NT:
begin if dwMajorVersion = 4 then
ResultStr := ResultStr + 'Windows NT '
else if (dwMajorVersion = 5) and (dwMinorVersion = 0) then
ResultStr := ResultStr + 'Windows 2000 '
else if (dwMajorVersion = 5) and (dwMinorVersion = 1) then
ResultStr := ResultStr + 'Windows XP '
else if (dwMajorVersion = 5) and (dwMinorVersion = 2) then
ResultStr := ResultStr + 'Windows 2003 ';
end; end; ResultStr := ResultStr + IntToStr(dwMajorVersion) + '.' + IntToStr(dwMinorVersion) + ' '; ResultStr := ResultStr + '(Build ' + IntToStr(LoWord(dwBuildNumber)) + ') '; if dwPlatformID = VER_PLATFORM_WIN32_NT then ResultStr := ResultStr + szCSDVersion; end; Result := ResultStr; end;