没有for windows 2003的,你可以测试一下,然后加上。<br>类似的代码很多。<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> osinfo: OSVERSIONINFO;<br>begin<br> osinfo.dwOSVersionInfoSize := sizeof(OSVERSIONINFO);<br> GetVersionEx(osinfo);<br> ShowMessage(InttoStr(osinfo.dwMajorVersion) + '.' + IntToStr(osinfo.dwMinorVersion) + '.' + IntToStr(osinfo.dwBuildNumber));<br>end;<br><br>{-----------------------------------------------------------------------------------------------------------}<br>function GetWindowsVersion: string;<br>var<br> // windows api structure<br> VersionInfo: TOSVersionInfo;<br>begin<br>// get size of the structure<br>VersionInfo.dwOSVersionInfoSize := SizeOf(VersionInfo);<br>// populate the struct using api call<br>GetVersionEx(VersionInfo);<br>// platformid gets the core platform<br>// major and minor versions also included.<br>with VersionInfo do<br>begin<br> case dwPlatformid of<br> 0 : begin<br> result := 'Windows 3.11';<br> end; // end 0<br><br> 1 : begin<br> case dwMinorVersion of<br> 0 : result := 'Windows 95';<br> 10: begin<br> if ( szCSDVersion[ 1 ] = 'A' ) then<br> Result :='Windows 98 SE'<br> else<br> Result := 'Windows 98';<br> end; // end 10<br> 90 : result := 'Windows Millenium';<br> else<br> result := 'Unknown Version';<br> end; // end case<br> end; // end 1<br><br> 2 : begin<br> case dwMajorVersion of<br> 3 : result := 'Windows NT ' +<br> IntToStr(dwMajorVersion) + '.' +<br> IntToStr(dwMinorVersion);<br> 4 : result := 'Windows NT ' +<br> IntToStr(dwMajorVersion) + '.' +<br> IntToStr(dwMinorVersion);<br> 5 : begin<br> case dwMinorVersion of<br> 0 : result := 'Windows 2000';<br> 1 : result := 'Windows Whistler';<br> end; // end case<br> end; // end 5<br> else<br> result := 'Unknown Version';<br> end; // end case<br> // service packs apply to the NT/2000 platform<br> if szCSDVersion <> '' then<br> result := result + ' Service pack: ' + szCSDVersion;<br> end; // end 2<br> else<br> result := 'Unknown Platform';<br> end; // end case<br> // add build info.<br> result := result + ', Build: ' +<br> IntToStr(Loword(dwBuildNumber)) ;<br>end; // end version info<br>end; // GetWindowsVersion<br>