您正在使用一款已经过时的浏览器!部分功能不能正常使用。
请尝试升级或使用
其他浏览器。
怎样得到当前的操作系统的版本号如win98,win95,winxp,win2000等 (15分)
bravercaohao
Unregistered / Unconfirmed
GUEST, unregistred user!
怎样用Delphi得到当前的操作系统的版本号如win98,win95,winxp,win2000等
delphi_lsl
Unregistered / Unconfirmed
GUEST, unregistred user!
yzhshi
Unregistered / Unconfirmed
GUEST, unregistred user!
很多,贴上来了一些。[
]<br>{--------------------------------------------------------------------------}<br>{1、获取当前Windows的版本}<br>const<br> cOsUnknown = -1;<br> cOsWin95 = 0;<br> cOsWin98 = 1;<br> cOsWin98SE = 2;<br> cOsWinME = 3;<br> cOsWinNT = 4;<br> cOsWin2000 = 5;<br> cOsXP = 6;<br><br><br>function GetOperatingSystem: Integer;<br>var<br> osVerInfo: TOSVersionInfo;<br> majorVer, minorVer: Integer;<br>begin<br> Result := cOsUnknown;<br> { set operating system type flag }<br> osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);<br> if GetVersionEx(osVerInfo) then<br> begin<br> majorVer := osVerInfo.dwMajorVersion;<br> minorVer := osVerInfo.dwMinorVersion;<br> case osVerInfo.dwPlatformId of<br> VER_PLATFORM_WIN32_NT: { Windows NT/2000 }<br> begin<br> if majorVer <= 4 then<br> Result := cOsWinNT<br> else if (majorVer = 5) and (minorVer = 0) then<br> Result := cOsWin2000<br> else if (majorVer = 5) and (minorVer = 1) then<br> Result := cOsXP<br> else<br> Result := cOsUnknown; <br> end; <br> VER_PLATFORM_WIN32_WINDOWS: { Windows 9x/ME } <br> begin<br> if (majorVer = 4) and (minorVer = 0) then <br> Result := cOsWin95 <br> else if (majorVer = 4) and (minorVer = 10) then <br> begin <br> if osVerInfo.szCSDVersion[1] = 'A' then <br> Result := cOsWin98SE <br> else <br> Result := cOsWin98; <br> end <br> else if (majorVer = 4) and (minorVer = 90) then <br> Result := cOsWinME <br> else <br> Result := cOsUnknown; <br> end; <br> else <br> Result := cOsUnknown; <br> end; <br> end<br> else<br> Result := cOsUnknown; <br>end; <br><br>{--------------------------------------------------------------------------}<br>{2、判断当前OS是否属于那一个}<br>function IsXP: Boolean;<br>var<br> OS: TOSVERSIONINFO;<br>begin<br> OS.dwOSVersionInfoSize := SizeOf(TOSVERSIONINFO);<br> GetVersionEx(osv);<br> Result := (OS.dwPlatformId = VER_PLATFORM_WIN32_NT) and<br> (OS.dwMajorVersion = 5) and (OS.dwMinorVersion = 1);<br>end;<br><br>function IsWin2000: Boolean; <br>var<br> OS: TOSVersionInfo; <br>begin <br> ZeroMemory(@OS, SizeOf(OS)); <br> OS.dwOSVersionInfoSize := SizeOf(OS); <br> GetVersionEx(OS); <br> Result := (OS.dwMajorVersion >= 5) and <br> (OS.dwPlatformId = VER_PLATFORM_WIN32_NT); <br>end; <br><br><br>function IsWinNT2: Boolean;<br>var <br> OS: TOSVersionInfo; <br>begin <br> ZeroMemory(@OS, SizeOf(OS)); <br> OS.dwOSVersionInfoSize := SizeOf(OS); <br> GetVersionEx(OS); <br> Result := OS.dwPlatformId = VER_PLATFORM_WIN32_NT; <br>end; <br><br>{ or: }<br><br>function IsWinNT2: Boolean;<br>begin<br> Result := Win32Platform = VER_PLATFORM_WIN32_NT;<br>end;<br><br><br>function IsWinME: Boolean;<br>var<br> OS: TOSVersionInfo;<br>begin<br> ZeroMemory(@OS, SizeOf(OS));<br> OS.dwOSVersionInfoSize := SizeOf(OS);<br> GetVersionEx(OS);<br> Result := (OS.dwMajorVersion = 4) and (OS.dwMinorVersion = 90) and<br> (OS.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS);<br>end;<br><br><br>function IsWin95: Boolean;<br>var<br> OS: TOSVersionInfo;<br>begin<br> ZeroMemory(@OS, SizeOf(OS));<br> OS.dwOSVersionInfoSize := SizeOf(OS);<br> GetVersionEx(OS);<br> Result := (OS.dwMajorVersion >= 4) and (OS.dwMinorVersion = 0) and<br> (OS.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS);<br>end;<br><br><br>uses registry;<br><br>function GetWindowsVersion: string;<br>var<br> VerInfo: TOsversionInfo;<br> PlatformId, VersionNumber: string;<br> Reg: TRegistry;<br>begin<br> VerInfo.dwOSVersionInfoSize := SizeOf(VerInfo);<br> GetVersionEx(VerInfo);<br> // Detect platform<br> Reg := TRegistry.Create; <br> Reg.RootKey := HKEY_LOCAL_MACHINE; <br> case VerInfo.dwPlatformId of <br> VER_PLATFORM_WIN32s: <br> begin <br> // Registry (Huh? What registry?) <br> PlatformId := 'Windows 3.1'; <br> end; <br> VER_PLATFORM_WIN32_WINDOWS: <br> begin <br> // Registry <br> Reg.OpenKey('/SOFTWARE/Microsoft/Windows/CurrentVersion', False); <br> PlatformId := Reg.ReadString('ProductName'); <br> VersionNumber := Reg.ReadString('VersionNumber'); <br> end; <br> VER_PLATFORM_WIN32_NT: <br> begin <br> // Registry<br> Reg.OpenKey('/SOFTWARE/Microsoft/Windows NT/CurrentVersion', False); <br> PlatformId := Reg.ReadString('ProductName'); <br> VersionNumber := Reg.ReadString('CurrentVersion'); <br> end; <br> end; <br> Reg.Free; <br> Result := PlatformId + ' (version ' + VersionNumber + ')'; <br>end; <br><br>procedure TForm1.Button1Click(Sender: TObject); <br>begin <br> Caption := GetWindowsVersion;<br>end;<br>
del520
Unregistered / Unconfirmed
GUEST, unregistred user!
或者用简单的方法。<br><br>你到注册表里面看看,也许会有收获。<br><br>HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion
bravercaohao
Unregistered / Unconfirmed
GUEST, unregistred user!
yzhshi 你好:<br> 你的代码在win98,winxp上通过但好像不能区分win2000和win2000 Server
yzhshi
Unregistered / Unconfirmed
GUEST, unregistred user!
2000 Server、Adv Server 、Personal<br>这个我倒还没有试验过,你看一下小版本是否有区别<br>就是下面的minorVer的数值<br> majorVer := osVerInfo.dwMajorVersion; 5<br> minorVer := osVerInfo.dwMinorVersion; ?<br>我这里没有环境,呵呵。
chinargb
Unregistered / Unconfirmed
GUEST, unregistred user!
lling
Unregistered / Unconfirmed
GUEST, unregistred user!
[
]太夸張了吧﹐yzhshi<br>buttonclick<br>var<br> osvi
sversioninfo;<br>begin<br> ovsi.dwosversioninfosize:=sizeof (osversioninfo);<br> getversionex(osvi); <br> label1.caption:=inttostr(osvi.dwmajorversion)+','<br> +inttostr(osvi.dwminorversion)+','<br> +inttostr(osvi.dwbuildnumber)+','<br> +inttostr(osve.dwplatformid)+','<br> +osvi.szcsdversion;<br>end;<br><br><br><br><br>
devecom
Unregistered / Unconfirmed
GUEST, unregistred user!