Returns the session id number for the session is currently associated with the system console. This function only returns a meaningful value on WinXP systems.
wtsGetActiveConsoleSessId()
None
(i) Returns an integer that represents the session identifier number for the terminal services session that is currently associated with the system console. Refer to the "Notes:" section for more information regarding the return values.
This function's purpose is to return the session id number for the terminal services session that is currently associated with the system console. This function only returns a meaningful value when called on WinXP. The reason for this is that only WinXP [not Win2K, not WinNT] implements the "fast user switching" functionality. The fast user switching functionality is implemented by making use of terminal services. WinXP simply performs a fast user switch by keeping a user's session logged on but in a disconnected state while it is not currently associated with the system console. As a logged on user's session is brought to the foreground, WinXP associates it with the system console hardware so that the user may interact with their session.
On Win2K and WinNT, this function always returns zero to indicate that the physical console has its own dedicated session that cannot be switched out with another one.
On WinXP, the actual session id number for the session currently associated with the system console will be returned. If the system console is currently in between two different sessions due to a fast user switch operationg being in-progress, then the return value of this function will be negative one [-1].
;Load 32-bit or 64-bit extender AddExtender( "WWWTS44I.DLL" , 0, "WWWTS64I.DLL" )
Title01 = 'Test wtsGetActiveConsoleSessId()' ErrorMode(@OFF) Result = wtsGetActiveConsoleSessId() RC = LastError() ErrorMode(@CANCEL) TempMsg = StrCat('wtsGetActiveConsoleSessId() RC = ',RC,@CRLF) TempMsg = StrCat(TempMsg,@CRLF,@CRLF,'Result = ',Result) Message(Title01,TempMsg) Exit