一个很菜的问题:怎样知道当前系统是 2000,98,XP,还是别的(50分)

  • 主题发起人 主题发起人 mllee
  • 开始时间 开始时间
M

mllee

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,谢谢!
 
没有for windows 2003的,你可以测试一下,然后加上。<br>类似的代码很多。<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; osinfo: OSVERSIONINFO;<br>begin<br>&nbsp; osinfo.dwOSVersionInfoSize := sizeof(OSVERSIONINFO);<br>&nbsp; GetVersionEx(osinfo);<br>&nbsp; ShowMessage(InttoStr(osinfo.dwMajorVersion) + '.' + IntToStr(osinfo.dwMinorVersion) + '.' + IntToStr(osinfo.dwBuildNumber));<br>end;<br><br>{-----------------------------------------------------------------------------------------------------------}<br>function GetWindowsVersion: string;<br>var<br>&nbsp; // windows api structure<br>&nbsp; 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>&nbsp; case dwPlatformid of<br>&nbsp; &nbsp; &nbsp;0 : begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result := 'Windows 3.11';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end; &nbsp; // end 0<br><br>&nbsp; &nbsp; &nbsp;1 : begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case dwMinorVersion of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 : result := 'Windows 95';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;10: begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ( szCSDVersion[ 1 ] = 'A' ) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result :='Windows 98 SE'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := 'Windows 98';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end; // end 10<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;90 : result := 'Windows Millenium';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result := 'Unknown Version';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; // end case<br>&nbsp; &nbsp; &nbsp; &nbsp; end; // end 1<br><br>&nbsp; &nbsp; &nbsp;2 : begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case dwMajorVersion of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3 : result := 'Windows NT ' +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IntToStr(dwMajorVersion) + '.' +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IntToStr(dwMinorVersion);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;4 : result := 'Windows NT ' +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IntToStr(dwMajorVersion) + '.' +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IntToStr(dwMinorVersion);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;5 : begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;case dwMinorVersion of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 : result := 'Windows 2000';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 : result := 'Windows Whistler';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end; &nbsp;// end case<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end; // end 5<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result := 'Unknown Version';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; // end case<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // service packs apply to the NT/2000 platform<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if szCSDVersion &lt;&gt; '' then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result := result + ' Service pack: ' + szCSDVersion;<br>&nbsp; &nbsp; &nbsp; &nbsp; end; // end 2<br>&nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; result := 'Unknown Platform';<br>&nbsp; end; // end case<br>&nbsp; // add build info.<br>&nbsp; result := result + ', Build: ' +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IntToStr(Loword(dwBuildNumber)) ;<br>end; // end version info<br>end; // GetWindowsVersion<br>
 
原来如此,谢谢!
 
后退
顶部