|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Finding Current/Active Session IDHow can I know if the session ID that a certain process is running on is actually the active session that he consol is connected to. I can get the session id of a process by Process P = Process.GetCurrentProcess(); And then check P.SessionID property. Anyone has an idea? Thanks If you are asking whether the process is running under Terminal Services or
local console then: If the SessionID is not 0 then it is running under TS. HTH "Ahmed Perlom" <per***@hotmail.com> wrote in message How can I know if the session ID that a certain process is running on isnews:OkN4fUp0GHA.1300@TK2MSFTNGP05.phx.gbl... Hi all, actually the active session that he consol is connected to. I can get the session id of a process by Process P = Process.GetCurrentProcess(); And then check P.SessionID property. Anyone has an idea? Thanks Hi, thanks for the reply. Actually, I want to know if a certain process is
running on the session (desktop) that has the keyboard and mouse. I understand that there might be more than one user session (using the fast user switch capability on WinXP) but I want to check for the session with the user currently interacting with the computer. I found the function "WTSGetActiveConsoleSessionId" from the terminal services, but it's an unmanaged code, and I was wondering if there is any ..NET managed way to get the same info. Thanks for the help, Show quote "Siva M" <shiva***@online.excite.com> wrote in message news:Oh82A4p0GHA.4956@TK2MSFTNGP04.phx.gbl... > If you are asking whether the process is running under Terminal Services > or > local console then: If the SessionID is not 0 then it is running under TS. > > HTH > > "Ahmed Perlom" <per***@hotmail.com> wrote in message > news:OkN4fUp0GHA.1300@TK2MSFTNGP05.phx.gbl... > Hi all, > > How can I know if the session ID that a certain process is running on is > actually the active session that he consol is connected to. I can get the > session id of a process by > > > > Process P = Process.GetCurrentProcess(); > > And then check P.SessionID property. > > > > Anyone has an idea? > > > > Thanks > > Hello,
Its easy to use the same API from .NET http://www.pinvoke.net/default.aspx/wtsapi32.WTSQuerySessionInformation "Ahmed Perlom" <per***@hotmail.com> wrote in message Hi, thanks for the reply. Actually, I want to know if a certain process isnews:e97yY%23q0GHA.2356@TK2MSFTNGP03.phx.gbl... running on the session (desktop) that has the keyboard and mouse. I understand that there might be more than one user session (using the fast user switch capability on WinXP) but I want to check for the session with the user currently interacting with the computer. I found the function "WTSGetActiveConsoleSessionId" from the terminal services, but it's an unmanaged code, and I was wondering if there is any ..NET managed way to get the same info. Thanks for the help, Show quote "Siva M" <shiva***@online.excite.com> wrote in message news:Oh82A4p0GHA.4956@TK2MSFTNGP04.phx.gbl... > If you are asking whether the process is running under Terminal Services > or > local console then: If the SessionID is not 0 then it is running under TS. > > HTH > > "Ahmed Perlom" <per***@hotmail.com> wrote in message > news:OkN4fUp0GHA.1300@TK2MSFTNGP05.phx.gbl... > Hi all, > > How can I know if the session ID that a certain process is running on is > actually the active session that he consol is connected to. I can get the > session id of a process by > > > > Process P = Process.GetCurrentProcess(); > > And then check P.SessionID property. > > > > Anyone has an idea? > > > > Thanks > > Thanks for the reply. I tried the PInvoke solution and it works. The
problem it is unmanaged code that need to run in full-trust mode. I was looking for a managed code solution that would run in a lower privilege. Cheers Show quote "Siva M" <shiva***@online.excite.com> wrote in message news:OIUvu%2320GHA.2400@TK2MSFTNGP03.phx.gbl... > Hello, > > Its easy to use the same API from .NET > http://www.pinvoke.net/default.aspx/wtsapi32.WTSQuerySessionInformation > > "Ahmed Perlom" <per***@hotmail.com> wrote in message > news:e97yY%23q0GHA.2356@TK2MSFTNGP03.phx.gbl... > Hi, thanks for the reply. Actually, I want to know if a certain process > is > running on the session (desktop) that has the keyboard and mouse. I > understand that there might be more than one user session (using the fast > user switch capability on WinXP) but I want to check for the session with > the user currently interacting with the computer. > > > > I found the function "WTSGetActiveConsoleSessionId" from the terminal > services, but it's an unmanaged code, and I was wondering if there is any > .NET managed way to get the same info. > > > > Thanks for the help, > > > > > > "Siva M" <shiva***@online.excite.com> wrote in message > news:Oh82A4p0GHA.4956@TK2MSFTNGP04.phx.gbl... >> If you are asking whether the process is running under Terminal Services >> or >> local console then: If the SessionID is not 0 then it is running under >> TS. >> >> HTH >> >> "Ahmed Perlom" <per***@hotmail.com> wrote in message >> news:OkN4fUp0GHA.1300@TK2MSFTNGP05.phx.gbl... >> Hi all, >> >> How can I know if the session ID that a certain process is running on is >> actually the active session that he consol is connected to. I can get >> the >> session id of a process by >> >> >> >> Process P = Process.GetCurrentProcess(); >> >> And then check P.SessionID property. >> >> >> >> Anyone has an idea? >> >> >> >> Thanks >> >> > > |
|||||||||||||||||||||||