设置为强制执行 ExitWindows( flag or EWX_FORCE,0);
不行的话给你个更毒的函数
const
NTDLL = 'NTDLL.DLL';
type
TNtShutdownSystemFun = function (SType:Cardinal):Boolean;Stdcall;
TMQQuitWinType = (MQQWT_Reboot, MQQWT_ShotDown, MQQWT_PowerOff);
function NtShutdownSystem(SType:Cardinal):Boolean;
var
NtShutdownSystemFun:TNtShutdownSystemFun;
HDLL:HINST;
begin
Result:=False;
HDLL:=LoadLibrary(NTDLL);
if HDLL<>0 then
begin
@NtShutdownSystemFun:=GetProcAddress(HDLL,'NtShutdownSystem');
Result:=NtShutdownSystemFun(SType);
FreeLibrary(HDLL);
end;
end;
//调用
function MQuickQuitWindows(QQType:TMQQuitWinType):Boolean;
var
SType:Cardinal;
begin
MSetProcPrivileges(GetCurrentProcess,SE_SHUTDOWN_NAME,True); //提升特权
Case QQType of
MQQWT_Reboot: SType:=1;
MQQWT_ShotDown: SType:=0;
MQQWT_PowerOff: SType:=2;
else
SType:=0;
end;
Result:= NtShutdownSystem(SType);
end;