exitwindowsex(EWX_REBOOT,0);用在win2000下为什么没反应(10分)

  • 主题发起人 主题发起人 no1
  • 开始时间 开始时间
N

no1

Unregistered / Unconfirmed
GUEST, unregistred user!
exitwindowsex(EWX_REBOOT,0);用在win2000下为什么没反应<br>AdjustTokenPrivileges怎么用
 
&nbsp; &nbsp;tkp &nbsp; &nbsp;: TTokenPrivileges;<br>&nbsp; &nbsp; tkpo &nbsp; : TTokenPrivileges; <br>&nbsp; &nbsp; zero: DWORD; <br>if GetVersionEx(osver)=false then &nbsp;//判断操作系统[:D]<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; zero := 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken);<br>&nbsp; &nbsp; &nbsp; &nbsp; LookupPrivilegeValue( nil,SE_SHUTDOWN_NAME, tkp.Privileges[ 0 ].Luid );<br>&nbsp; &nbsp; &nbsp; &nbsp; tkp.PrivilegeCount:= 1;<br>&nbsp; &nbsp; &nbsp; &nbsp; tkp.Privileges[0].Attributes:= SE_PRIVILEGE_ENABLED;<br>&nbsp; &nbsp; &nbsp; &nbsp; AdjustTokenPrivileges( hToken, False, tkp, SizeOf( TTokenPrivileges ), tkpo, zero );<br>&nbsp; &nbsp; &nbsp; &nbsp; ExitWindowsex(EWX_SHUTDOWN,0);//一共可以有4种,我只列出2种<br>&nbsp; &nbsp; &nbsp; &nbsp; ExitWindowsex(EWX_REBOOT,0); &nbsp; <br>end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 
我在2000下试过了,没反应
 
完整的代码<br>program ShutDown;<br><br>uses<br>&nbsp; Windows;<br><br>{$R *.res}<br>var<br>&nbsp; hToken : THandle;<br>&nbsp; tkp : TTokenPrivileges;<br>&nbsp; tkpo : TTokenPrivileges;<br>&nbsp; zero : DWORD;<br><br>function IsWinnt:Boolean;<br>var<br>&nbsp; VerInfo: _OSVERSIONINFO;<br>begin<br>&nbsp; VerInfo.dwOSVersionInfoSize := sizeof(VerInfo);<br>&nbsp; GetVersionEx(VerInfo);<br>&nbsp; if VerInfo.dwPlatformId = VER_PLATFORM_WIN32_NT then<br>&nbsp; &nbsp; result := true<br>&nbsp; else<br>&nbsp; &nbsp; result := false;<br>end;<br>begin<br>&nbsp; if not IsWinnt then<br>&nbsp; &nbsp; if MessageBox(0,'Shutdown?','Shutdown',MB_OKCANCEL or MB_ICONINFORMATION)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = idok then<br>&nbsp; &nbsp; &nbsp; ExitwindowsEx(EWX_REBOOT, 0);<br>&nbsp; zero:=0;<br>&nbsp; OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken);<br>&nbsp; LookupPrivilegeValue( nil, 'SeShutdownPrivilege' , tkp.Privileges[ 0 ].Luid );<br>&nbsp; tkp.PrivilegeCount := 1;<br>&nbsp; tkp.Privileges[ 0 ].Attributes := SE_PRIVILEGE_ENABLED;<br>&nbsp; AdjustTokenPrivileges( hToken, False, tkp, SizeOf( TTokenPrivileges ), tkpo, zero );<br>&nbsp; if MessageBox(0,'Shutdown?','Shutdown',MB_OKCANCEL or MB_ICONINFORMATION) = idok then<br>&nbsp; &nbsp; ExitWindowsEx( EWX_FORCE or EWX_REBOOT, 0);<br>end.
 
多人接受答案了。
 
后退
顶部