帮帮忙!看一下下面的代码的问题在哪?100分拜托!(100分)

  • 主题发起人 主题发起人 小乙
  • 开始时间 开始时间

小乙

Unregistered / Unconfirmed
GUEST, unregistred user!
下面是获取WINDOWS版本的一段代码,使用了API函数:GetVersionEx(),<br>可以运行时怎么总是出现“未定义的标识符:VER_PLATFROM_WIN32_S”?<br>这个可是GetVersionEx()函数的参数啊?!<br><br>procedure TForm2.FormCreate(Sender: TObject);<br>const<br>&nbsp; SOSWIN98='Windows98';<br>&nbsp; SOSWinNT='Windows NT';<br>var<br>&nbsp;VI:TOSVersionInfo;<br>begin<br>&nbsp;VI.dwOSVersionInfoSize:=SizeOf(VI);<br>&nbsp;GetVersionEx(VI);<br>&nbsp;with ListBox1.Items,VI do<br>&nbsp; begin<br>&nbsp; Clear;<br>&nbsp; Add(Format('Os Version %d,%d',[dwMajorVersion,dwMinorVersion]));<br>&nbsp; Add(Format('Build Number %d',[dwBuildNumber]));<br>&nbsp; case dwPlatformID of<br>&nbsp; VER_PLATFROM_WIN32_S:Add(Format('Platform %s',[SOSWin98]));<br>&nbsp; VER_PLATFORM_WIN32_NT:Add(Format('Platform %s',[SOSWinNT]));<br>&nbsp; end;<br>&nbsp;end;<br>end;
 
是 VER_PLATFORM_WIN32S<br>而不是:VER_PLATFORM_WIN32_S
 
procedure TForm1.FormCreate(Sender: TObject);<br>const<br>&nbsp; SOSWIN98='Windows98';<br>&nbsp; SOSWinNT='Windows NT';<br>var<br>&nbsp;VI:TOSVersionInfo;<br>begin<br>&nbsp;VI.dwOSVersionInfoSize:=SizeOf(VI);<br>&nbsp;GetVersionEx(VI);<br>&nbsp;with ListBox1.Items,VI do<br>&nbsp; begin<br>&nbsp; Clear;<br>&nbsp; Add(Format('Os Version %d,%d',[dwMajorVersion,dwMinorVersion]));<br>&nbsp; Add(Format('Build Number %d',[dwBuildNumber]));<br>&nbsp; case dwPlatformID of VER_PLATFORM_WIN32S: &nbsp;Add(Format('Platform %s',[SOSWin98]));<br>&nbsp; VER_PLATFORM_WIN32_NT:Add(Format('Platform %s',[SOSWinNT]));<br>&nbsp; end;<br>&nbsp;end;<br>end;<br>end.<br>
 
&nbsp;VER_PLATFORM_WIN32s = 0;<br>&nbsp; VER_PLATFORM_WIN32_WINDOWS = 1;<br>&nbsp; VER_PLATFORM_WIN32_NT=2;
 
都不行,不是_S的问题,我去掉_了,但还是出现<br>“未申报的标识符:VER_PLATFORM_WIN32S"的错误提示!<br>“未申报的标识符:VER_PLATFORM_WIN32_WINDOWS"的错误提示!
 
以下代码是我正在使用的,保证有效,其中lblOS是一个LABEL,用以显示版本号:<br><br>var<br>&nbsp; &nbsp;Platform: string;<br>&nbsp; &nbsp;BuildNumber: Integer;<br>begin<br>&nbsp; &nbsp;case Win32Platform of<br>&nbsp; &nbsp; &nbsp; VER_PLATFORM_WIN32_WINDOWS:<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (Win32MajorVersion=4) and (Win32MinorVersion=10) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Platform :='Windows 98'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Platform := 'Windows 95';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BuildNumber := Win32BuildNumber and $0000FFFF;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; VER_PLATFORM_WIN32_NT:<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (Win32MajorVersion=5) and (Win32MinorVersion=0) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Platform := 'Windows 2000'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else if (Win32MajorVersion=5) and (Win32MinorVersion=1) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Platform := 'Windows XP'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else if (Win32MajorVersion=4) and (Win32MinorVersion=0) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Platform := 'Windows NT 4.0'<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Platform := 'Windows NT'; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BuildNumber := Win32BuildNumber;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Platform := 'Windows';<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BuildNumber := 0;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp;end;<br>&nbsp; &nbsp;if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) or<br>&nbsp; &nbsp; &nbsp; (Win32Platform = VER_PLATFORM_WIN32_NT) then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; if Win32CSDVersion = '' then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lblOS.Caption := lblOS.Caption+Format('%s 版本 %d.%d '+#13+' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(内部版本 %d)', [Platform, Win32MajorVersion,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Win32MinorVersion, BuildNumber])<br>&nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lblOS.Caption := lblOS.Caption+Format('%s 版本 %d.%d '+#13+' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(内部版本 %d: %s)', [Platform, Win32MajorVersion,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Win32MinorVersion, BuildNumber, Win32CSDVersion]);<br>&nbsp; &nbsp;end<br>&nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; lblOS.Caption := lblOS.Caption+Format('%s %d.%d', [Platform, Win32MajorVersion,<br>&nbsp; &nbsp; &nbsp; Win32MinorVersion])<br>end;<br>
 
to thinknet:<br>恩那!确实比我的好用啊!
 
后退
顶部