代码function GetWindowsVersion: string; var AWin32Version: Extended; os: string; begin os := 'Windows'; AWin32Version := StrToFloat(Format('%d.%d',[Win32MajorVersion,Win32MinorVersion])); if Win32Platform = ver_platform_win32s then Result := os + '32' else if Win32Platform = ver_platform_win32_windows then begin if AWin32Version = 4.0 then Result := os + '95' else if AWin32Version = 4.1 then Result := os + '98' else if AWin32Version = 4.9 then Result := os + 'Me' else Result := os + '9x' end else if Win32Platform = VER_PLATFORM_WIN32_NT then begin if AWin32Version = 3.15 then Result := os + 'NT 3.51' else if AWin32Version = 4.0 then Result := os + 'NT 4.0' else if AWin32Version = 5.0 then Result := os + '2000' else if AWin32Version = 5.1 then Result := os + 'XP' else if AWin32Version = 5.2 then Result := os + '2003' else if AWin32Version = 6.0 then Result := os + 'Vista' else if AWin32Version = 6.1 then Result := os + '7' else Result := os ; end else Result := os + '??'; Result := Result + ' ' +GetWindowsVersionString; end;
代码function GetWindowsVersionString: AnsiString; var VI: TOSVersionInfoA; begin VI.dwOSVersionInfoSize := SizeOf(TOSVersionInfoA); if GetVersionExA(VI) then with VI do Result := Trim(Format('%d.%d build %d %s', [dwMajorVersion,dwMinorVersion,dwBuildNumber,szCSDVersion])) else Result := ''; end;