ExitWindowsEx 的使用?(50分)

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

brook_qin

Unregistered / Unconfirmed
GUEST, unregistred user!
在使用ExitWindowsEx之前先把 程序优先权设为高,当执行ExitWindowsEx后application.Terminate,现在的问题是当把ExitWindowsEx设为EWX_LOGOFF可以执行,但是报错,dll为初始化,如果设为EWX_SHUTDOWN,程序耗无反应,请问是什么原因?请大家帮帮忙
 
不用执行application.Terminate
 
去掉application.Terminate 还是没反应啊
 
SHUTDOWN的话,还得超级用户才可以用
 
我是用administrator登陆的呀,但是无法执行,奇怪的是EWX_LOGOFF可以执行[:(][:(]
 
procedure TForm1.Button2Click(Sender: TObject);<br>var<br>&nbsp; VerInfo:TOSVersionInfo;<br>&nbsp; hToken:THANDLE;<br>&nbsp; tkp:TOKEN_PRIVILEGES;<br>&nbsp; Nothing:Cardinal;<br>begin<br>&nbsp; VerInfo.dwOSVersionInfoSize:=SizeOf(VerInfo);<br>&nbsp; GetVersionEx(VerInfo);<br>&nbsp; if VerInfo.dwPlatformId=VER_PLATFORM_WIN32_NT then<br>&nbsp; Begin<br>&nbsp; &nbsp; OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken);<br>&nbsp; &nbsp; LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);<br>&nbsp; &nbsp; tkp.PrivilegeCount:= 1;<br>&nbsp; &nbsp; tkp.Privileges[0].Attributes:= SE_PRIVILEGE_ENABLED;<br>&nbsp; &nbsp; AdjustTokenPrivileges(hToken, FALSE, tkp, 0,nil, Nothing);<br>&nbsp; End;<br>&nbsp; &nbsp; ExitWindowsEx(EWX_POWEROFF,0);//这句就是关机<br>&nbsp; //ExitWindowsEx(EWX_REBOOT,0);<br>end;
 
问题解决了,谢谢各位
 
后退
顶部