关于ExitWindowsEx()函数的参数 (50分)

  • 主题发起人 主题发起人 bjaman
  • 开始时间 开始时间
B

bjaman

Unregistered / Unconfirmed
GUEST, unregistred user!
1.怎样判断当前系统是95/98/2000/XP/2003/NT?<br>2.关于ExitWindowsEx()函数的参数:当ExitWindowsEx(EWX_SHUTDOWN,0),只能关闭98系统的电源,而不能关闭2000Sever的电源;当ExitWindowsEx(EWX_POWEROFF,0),只能关闭2000系统的电源,而不能关闭98系统的电源.这是怎么一回事?这两个参数究竟有什么区别?请熟悉它的朋友们讲解一下。谢谢了。
 
通过GetVersionEx函数获得Windows的版本信息<br>Procedure Tform1.Button2Click(sender:TObject);<br>var<br>&nbsp; OSVI:OSVERSIONINFO;<br>begin<br>&nbsp; &nbsp;OSVI.dwOSversioninfoSize:=Sizeof(OSVERSIONINFO);<br>&nbsp; GetVersionEx(OSVI);<br>&nbsp; label1.Caption:=IntToStr(OSVI.dwMinorVersion)+','<br>&nbsp; +IntToStr(OSVI.dwMinorVersion)+','<br>&nbsp; +IntToStr(OSVI.dwBuildNumber)+','<br>&nbsp; +IntToStr(OSVI.dwPlatformId)+','<br>&nbsp; +OSVI.szCSDVersion;<br>end;
 
MSDN中有说明!楼主是英文不好吗?<br>可惜我英文也不好.<br>
 
关于这个问题,EXITWINDOWSEX()中的参数,我们可以这样理解。因为WINDOWS2000 比WINDOWS98的安全性要高。所以在WINDOWS2000中能用的在98中就不以定能用。EWX_POEWEROFF是一个系统键,而EWX_SHUTDOWN则不一样。
 
procedure TForm1.Button1Click(Sender: TObject);<br>var<br>P:OSVERSIONINFO;<br>begin<br>&nbsp; &nbsp;P.dwOSVersionInfoSize := SizeOf(P);<br>&nbsp; &nbsp;GetVersionEx(P);<br>&nbsp; &nbsp;showmessage(p.szCSDVersion);<br>&nbsp; &nbsp;case p.dwMajorVersion of<br>&nbsp; &nbsp; 3: ShowMessage('nt 3.51');<br>&nbsp; &nbsp; 4:<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; case p.dwMinorVersion of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0: if p.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowMessage('95')<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShowMessage('nt 4.0');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10: ShowMessage('98');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 90: ShowMessage('me');<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; 5:<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; case p.dwMinorVersion of<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0: ShowMessage('Windows 2000');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1: ShowMessage('xp');<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; end;<br><br>end;<br>end;
 
第一个问题,谢谢苗老弟和yutaoku朋友的解答。知道该怎么做了。因这几天上网不便,隔几日再发分。谢过了。<br>第二个问题,感谢羊兄的指点和雨兄弟的参与。其他朋友是否还有一些高见,在下愿继续洗耳恭听。。。
 
EWX_SHUTDOWN:(2000无法关闭的原因可能是)<br>All file buffers have been flushed to disk, and all running processes have stopped. <br>Specifying this flag will not shut down the power to the system even if it supports the power-off feature. You must specify EWX_POWEROFF to do this.<br><br>但power-off 标志是什么?没找到!<br>
 
EWX_POWEROFF=8,在Windows单元里有定义,但是我没找到详细的说明。点F1帮助找不到相关信息。<br>也许我只能判断当前系统是什么再用相应的参数来解决了。那么EWX_POWEROFF参数对XP、NT、2003的操作效果是否与2000相同?EWX_SHUTDOWN参数对98、95、ME的操作效果是否相同呢?请知道的朋友给个提示。因为我没有可能装那么多系统逐个试过去。。。
 
不用我多说了,bjaman,
 
参考贴:http://delphibbs.com/delphibbs/dispq.asp?lid=2472876
 
后退
顶部