EWX_FORCE 强迫中止没有响应的进程
EWX_LOGOFF 中止进程,然后注销
EWX_SHUTDOWN 关掉系统电源(如果可能的话,ATX电源就可以)
EWX_REBOOT 重新引导系统
EWX_SHUTDOWN 关闭系统
1.WIN 9X实现 注销 关机 重启------------------------------------------------------------------------------------------
1.--定义常数
const
EWX_LOGOFF=0; //重新启动计算机并切换到MS-DOS方式
EWX_SHUTDOWN=1;//关闭计算机
EWX_REBOOT=2; //重新启动计算机
EWX_FORCE=4; //关闭所有程序并以其他用户身份登录
2.--执行
ExitWindowsEx(How,0);
2.WIN 2K实现- 注销 关机 重启-------------------------------------------------------------------------------------------
1.--关机
var
hToken:THandle;
tkp : TOKEN_PRIVILEGES;
ReturnLength : DWord;
begin
if (not OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_ALL_ACCESS or TOKEN_QUERY, hToken))then
begin
application.Terminate;
end;
LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);
tkp.PrivilegeCount := 1;
tkp.Privileges[0].Attributes :=SE_PRIVILEGE_ENABLED;
ReturnLength :=0;
AdjustTokenPrivileges(hToken, FALSE, tkp, 0,nil,ReturnLength);
if (GetLastError() <> ERROR_SUCCESS) then
begin
application.Terminate;
end;
if (not ExitWindowsEx(EWX_POWEROFF, 0)) then
begin
application.Terminate;
end;
end;
end.
2.--重启
var
hToken:THandle;
tkp : TOKEN_PRIVILEGES;
ReturnLength : DWord;
begin
if (not OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or TOKEN_ALL_ACCESS or TOKEN_QUERY, hToken))then
begin
application.Terminate;
end;
LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);
tkp.PrivilegeCount := 1;
tkp.Privileges[0].Attributes :=SE_PRIVILEGE_ENABLED;
ReturnLength :=0;
AdjustTokenPrivileges(hToken, FALSE, tkp, 0,nil,ReturnLength);
if (GetLastError() <> ERROR_SUCCESS) then
begin
application.Terminate;
end;
if (not ExitWindowsEx(EWX_REBOOT, 0)) then
begin
application.Terminate;
end;
end;
end.
3.--注销
exitwindowsex(ewx_force,0); //注销
关闭显示器
SendMessage(Application.Handle, wm_SysCommand, SC_MonitorPower, 1) ;
注销 关机 重启
最新推荐文章于 2024-03-27 22:46:27 发布