procedure CloseWindow(Flag:integer);
var
hToken:Thandle;
tkp,tkDumb:TTokenPrivileges;
DoubInt:dword;
begin
if Win32PlatForm=VER_PLATFORM_WIN32_NT then
begin
FillChar(tkp,Sizeof(tkp),0);
if (OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,hToken)) then
begin
tkp.PrivilegeCount:=1;
tkp.Privileges[0].Attributes :=SE_PRIVILEGE_ENABLED;
AdjustTokenPrivilege(hToken,False,tkp,sizeof(tkDumb),tkDumb,DumbInt);
end;
end;
if Flag=0 then
ExitWindewEx(Ewx_Reboot,0) //重启
else
ExitWindewEx(Ewx_SHUTDOWN,0); //关机
end;