Try this:
HANDLE token;OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token );LUID luid;LookupPrivilegeValue( NULL, SE_SHUTDOWN_NAME, &luid ); TOKEN_PRIVILEGES p;p.PrivilegeCount = 1;p.Privileges[0].Luid = luid;p.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;AdjustTokenPrivileges( token, false, &p, 0, NULL, 0 );CloseHandle( token );ExitWindowsEx(EWX_POWEROFF, NULL);
And if it doesn''t work check the return values.