//在初始化的时候获取权限 var hToken: THandle; Tkp: TTokenPrivileges; Zero: DWORD; begin OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken); LookupPrivilegeValue(nil, 'SeShutdownPrivilege', Tkp.Privileges[0].Luid); Tkp.PrivilegeCount := 1; Tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, False, Tkp, SizeOf(TTokenPrivileges), nil, Zero); end; --------****--------- ExitWindowsEx(EWX_SHUTDOWN, 0);//close ExitWindowsEx(EWX_REBOOT, 0);//reoot
ExitWindowsEx(EWX_LOGOFF,0)// 注销