#53 use of InitiateSystemShutdownEx

open
nobody
None
5
2010-01-12
2010-01-12
C.Trauma
No

According to the MSDN docs for ExitWindowsEx :

The ExitWindowsEx function returns as soon as it has initiated the shutdown process. The shutdown or logoff then proceeds asynchronously. The function is designed to stop all processes in the caller's logon session. Therefore, if you are not the interactive user, the function can succeed without actually shutting down the computer. If you are not the interactive user, use the InitiateSystemShutdown or InitiateSystemShutdownEx function.

So if you log into a system remotely using remote desktop and have FDM running and set to shutdown the system after completing, the system will not shutdown, but hang on a dialog box that warns the user.

Adding a line like this:

InitiateSystemShutdownEx(NULL,_T("FDM Download Completed, Shutdown Requested...."),20,TRUE,FALSE,0x80000000);

instead of this:

ExitWindowsEx ((UINT) uFlags, 0);

In the fsScheduleMgr::_threadShutdown() function in fsScheduleMgr.cpp

The only potential problem would be forcing apps to close with unsaved data by setting the bForceAppsClosed to TRUE to avoid the dialog box.

I'm testing this now in my VS2005 FDM port now..

Discussion

  • C.Trauma
    C.Trauma
    2010-01-12

    confirmed this change solves the problem with terminal services and ExitWindowEx