Identify Console Session (via mstsc /console or via physical console)

  • Thread starter Thread starter Markus
  • Start date Start date
M

Markus

Guest
Hello,

it seems like a simple question but we have major problems identifying, if
our application runs in the console session or in a "normal" terminal
services session.

Using GetSystemMetrics with SM_REMOTESESSION fails, as it will give us
always 1 if we connect to Server 2003 via mstsc. This is in clear
contradiction to the documentation:

--

SM_REMOTESESSION

This system metric is used in a Terminal Services environment. If the
calling process is associated with a Terminal Services client session, the
return value is nonzero. If the calling process is associated with the
Terminal Server console session, the return value is 0. The console session
is not necessarily the physical console. For more information, see
WTSGetActiveConsoleSessionId.

--

Testing for SessionId 0 seemed to work in Server 2003, but not in Longhorn,
where even the physical console can have a sessionid other than 0.

Has anyone any idea how to solve this?

Nice regards,
Markus
 
Re: Identify Console Session (via mstsc /console or via physical console)

Would the WTSAPI WTSGetActiveConsoleSessionId provide the information you
need?
For more info on WTSAPI, please refer to:
http://msdn2.microsoft.com/en-us/library/aa383468.aspx

Thanks
Soo Kuan


--
This posting is provided "AS IS" with no warranties, and confers no rights.

"Markus" <markusw@nospam.nospam> wrote in message
news:eQ91qQjFIHA.3400@TK2MSFTNGP03.phx.gbl...
> Hello,
>
> it seems like a simple question but we have major problems identifying, if
> our application runs in the console session or in a "normal" terminal
> services session.
>
> Using GetSystemMetrics with SM_REMOTESESSION fails, as it will give us
> always 1 if we connect to Server 2003 via mstsc. This is in clear
> contradiction to the documentation:
>
> --
>
> SM_REMOTESESSION
>
> This system metric is used in a Terminal Services environment. If the
> calling process is associated with a Terminal Services client session, the
> return value is nonzero. If the calling process is associated with the
> Terminal Server console session, the return value is 0. The console
> session is not necessarily the physical console. For more information, see
> WTSGetActiveConsoleSessionId.
>
> --
>
> Testing for SessionId 0 seemed to work in Server 2003, but not in
> Longhorn, where even the physical console can have a sessionid other than
> 0.
>
> Has anyone any idea how to solve this?
>
> Nice regards,
> Markus
>
>
 
Re: Identify Console Session (via mstsc /console or via physical console)

In Windows 2008, your application will *never* run in session0,
unless it is a service. Session 0 is not an interactive session
anymore.
Documented here:

Console Behavior Differences in Longhorn Server Terminal Services
http://blogs.msdn.com/ts/archive/2006/11/27/console-behavior-
differences-in-longhorn-server-terminal-services.aspx
_________________________________________________________
Vera Noest
MCSE, CCEA, Microsoft MVP - Terminal Server
TS troubleshooting: http://ts.veranoest.net
___ please respond in newsgroup, NOT by private email ___

"Markus" <markusw@nospam.nospam> wrote on 24 okt 2007 in
microsoft.public.windows.terminal_services:

> Hello,
>
> it seems like a simple question but we have major problems
> identifying, if our application runs in the console session or
> in a "normal" terminal services session.
>
> Using GetSystemMetrics with SM_REMOTESESSION fails, as it will
> give us always 1 if we connect to Server 2003 via mstsc. This is
> in clear contradiction to the documentation:
>
> --
>
> SM_REMOTESESSION
>
> This system metric is used in a Terminal Services environment.
> If the calling process is associated with a Terminal Services
> client session, the return value is nonzero. If the calling
> process is associated with the Terminal Server console session,
> the return value is 0. The console session is not necessarily
> the physical console. For more information, see
> WTSGetActiveConsoleSessionId.
>
> --
>
> Testing for SessionId 0 seemed to work in Server 2003, but not
> in Longhorn, where even the physical console can have a
> sessionid other than 0.
>
> Has anyone any idea how to solve this?
>
> Nice regards,
> Markus
 
Back
Top