如判断当前windows是95/98/2000/nt?我要API和调用方法(50分)

  • 主题发起人 主题发起人 freecom
  • 开始时间 开始时间
DWORD GetVersion(VOID)<br>BOOL GetVersionEx(<br><br>&nbsp; &nbsp; LPOSVERSIONINFO lpVersionInformation // pointer to version information structure<br>&nbsp; &nbsp;);
 
type<br>&nbsp; SystemInfoRecord = record<br>&nbsp; &nbsp; Version &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :string;<br>&nbsp; &nbsp; Plattform &nbsp; &nbsp; &nbsp; &nbsp; : string;<br>&nbsp; &nbsp; PlattId &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : DWORD;<br>end;<br><br>var &nbsp; SysInfoRec: SystemInfoRecord;<br><br>procedure TMainForm.GetOSVersionInfo;<br><br>&nbsp; function Plat(Pl: DWORD): string;<br>&nbsp; begin<br>&nbsp; &nbsp; case Pl of<br>&nbsp; &nbsp; &nbsp; VER_PLATFORM_WIN32s: &nbsp; &nbsp; &nbsp; &nbsp;result := 'Win32s on Windows 3.1';<br>&nbsp; &nbsp; &nbsp; VER_PLATFORM_WIN32_WINDOWS: result := 'Win32 on Windows 95';<br>&nbsp; &nbsp; &nbsp; VER_PLATFORM_WIN32_NT: &nbsp; &nbsp; &nbsp;result := 'Windows NT';<br>&nbsp; &nbsp; &nbsp; else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result := '???';<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br><br>begin<br><br>&nbsp; with OSVerInfo, SysInfoRec do begin<br>&nbsp; &nbsp; dwOSVersionInfoSize := SizeOf(OSVerInfo);<br>&nbsp; &nbsp; if GetVersionEx(OSVerInfo) then;<br>&nbsp; &nbsp; Version := Format('%d.%d (%d.%s)',[dwMajorVersion, dwMinorVersion,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (dwBuildNumber and $FFFF), szCSDVersion]);<br>&nbsp; &nbsp; Plattform := Plat(dwPlatformId);<br>&nbsp; &nbsp; PlattID &nbsp; := dwPlatformId;<br>&nbsp; end;<br>end;
 
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
 
xk最全,terry_lzs也不错,chenlili太简单。
 
后退
顶部