DosSelectSession allows a parent session to switch one of its child sessions to the foreground. The session specified will not be brought to the foreground unless the parent session or one of its descendant sessions is currently executing in the foreground.
The foreground session for windowed applications is the session of the application that owns the window focus.
DosSelectSession may only be issued by a parent session to select itself or a child session. DosSelectSession may not be used to select a grandchild session, or any other descendant session beyond a child session. DosSelectSession may only be issued by the process that originally started the specified session (idSession) through DosStartSession.
DosSelectSession may only be used to select child sessions that were originally started by the caller with DosStartSession specifying a value of 1 for Related. That is, sessions started as independent sessions may not be selected through DosSelectSession.
When DosSelectSession is issued, the session specified will not be brought to the foreground unless the parent session or one of its descendant sessions is currently executing in the foreground.
Return code ERROR_SMG_NO_TARGET_WINDOW is a warning that the session might not be brought to the foreground. If the selected session is a Presentation Manager (PM) application, its window must be created with the FCF_TASKLIST flag bit set on. If the window is created with this bit set off, its session cannot be selected using DosSelectSession, and ERROR_SMG_NO_TARGET_WINDOW is returned.
If you issue DosSelectSession before creating the PM window of the selected session, ERROR_SMG_NO_TARGET_WINDOW is returned. However, if the PM window of the selected session is subsequently created with the FCF_TASKLIST flag bit set on, the window is brought to the foreground if the issuer of DosSelectSession still owns the foreground focus.
If a session still exists but its window has been destroyed, and you issue DosSelectSession for that session, ERROR_SMG_NO_TARGET_WINDOW is returned.