function GetWindowsVersion: String; const cOsUnknown : Integer = -1; cOsWin95 : Integer = 0; cOsWin98 : Integer = 1; cOsWin98SE : Integer = 2; cOsWinME : Integer = 3; cOsWinNT : Integer = 4; cOsWin2000 : Integer = 5; cOsWinXP : Integer = 6; cOsWin7 : Integer = 7; var osVerInfo : TOSVersionInfo; majorVer, minorVer, VersionCode: Integer; begin osVerInfo.dwOSVersionInfoSize := SizeOf( TOSVersionInfo ); if ( GetVersionEx( osVerInfo ) ) then begin majorVer := osVerInfo.dwMajorVersion; minorVer := osVerInfo.dwMinorVersion; case ( osVerInfo.dwPlatformId ) of VER_PLATFORM_WIN32_NT : { Windows NT/2000/XP/7 } begin if ( majorVer <= 4 ) then VersionCode := cOsWinNT else if ( ( majorVer = 5 ) and ( minorVer= 0 ) ) then VersionCode := cOsWin2000 else if ( ( majorVer = 5) and ( minorVer = 1 ) ) then VersionCode := cOsWinXP else //我没装 Win7,这里的 5 和 2 是猜测的 //请安装了 Win7 的朋友测试一下究竟是多少 if ( ( majorVer = 5) and ( minorVer = 2 ) ) then VersionCode := cOsWin7 else VersionCode := cOsUnknown; end; VER_PLATFORM_WIN32_WINDOWS : { Windows 9x/ME } begin if ( ( majorVer = 4 ) and ( minorVer = 0 ) ) then VersionCode := cOsWin95 else if ( ( majorVer = 4 ) and ( minorVer = 10 ) ) then begin if ( osVerInfo.szCSDVersion[ 1 ] = 'A' ) then VersionCode := cOsWin98SE else VersionCode := cOsWin98; end else if ( ( majorVer = 4) and ( minorVer = 90 ) ) then VersionCode := cOsWinME else VersionCode := cOsUnknown; end; else VersionCode := cOsUnknown; end; { Final del Case} end else VersionCode := cOsUnknown; {Final del if} if ( VersionCode = cOsUnknown ) then Result := '(sistema no reconocido)' else if ( VersionCode = cOsWin95 ) then Result := 'Microsoft Windows 95' else if ( VersionCode = cOsWin98 ) then Result := 'Microsoft Windows 98' else if ( VersionCode = cOsWin98SE ) then Result := 'Microsoft Windows 98 Second Edition' else if ( VersionCode = cOsWinME ) then Result := 'Microsoft Windows Millennium Edition' else if ( VersionCode = cOsWinNT ) then Result := 'Microsoft Windows NT' else if ( VersionCode = cOsWin2000 ) then Result := 'Microsoft Windows 2000' else if ( VersionCode = cOsWinXP ) then Result := 'Microsoft Windows XP' else if ( VersionCode = cOsWin7 ) then Result := 'Microsoft Windows 7' else Result := 'Microsoft Windows'; Result:= Result + ' (Build '+IntToStr(osVerInfo.dwBuildNumber)+') ' + osVerInfo.szCSDVersion; end;