Today I have a complain that the administrator account is asking for
the password, they do not know the password and do not have a keyboard
to type it in.
I was wondering if anyone has run into this problem, everything worked
flawlessly until this incident.
I do have some code to shutdown the computer with power button pressed,
I wonder if it has anything to do with this, because occasionally this
code would only log you off, not shut down the computer.
Here is the code involved
m_shutdown_msg = RegisterWindowMessage(WM_SYSTEM_SHUTDOWN);
SendMessage(HWND_BROADCAST, m_shutdown_msg, 0, 0);
Sleep(1000);
//change privilege and then force shutdown
HANDLE hProcessHandle = GetCurrentProcess();
HANDLE hTokenHandle;
TOKEN_PRIVILEGES NewPriv;
OpenProcessToken(hProcessHandle, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&hTokenHandle);
NewPriv.PrivilegeCount = 1;
NewPriv.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
LookupPrivilegeValue("", SE_SHUTDOWN_NAME,
&NewPriv.Privileges[0].Luid); //look up privileges
AdjustTokenPrivileges(hTokenHandle, FALSE, &NewPriv, 0, NULL, NULL);
//adjust with new token
ExitWindowsEx(EWX_POWEROFF| EWX_FORCE, 0); //turn off (force = does
not ask programs to save data)
|