InitiateSystemShutdownEx:
HANDLE hToken;
OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&hToken);
TOKEN_PRIVILEGES tk;
tk.PrivilegeCount = 1;
tk.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
LookupPrivilegeValue(NULL, TEXT("SeShutdownPrivilege"), &tk.Privileges[0].Luid);
AdjustTokenPrivileges(hToken, FALSE, &tk, 0, NULL, 0);
InitiateSystemShutdownEx(NULL, NULL, 0, FALSE, FALSE, 0);
As far as I can tell, the advantage of this in the solution ExitWindowsExis that the calling process should not belong to the active user.
source
share