Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2006

Tip: Looking for answers? Try searching our database.

Finding Current/Active Session ID

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ahmed Perlom - 07 Sep 2006 16:48 GMT
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
Siva M - 07 Sep 2006 17:42 GMT
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

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
Ahmed Perlom - 07 Sep 2006 19:58 GMT
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,

> If you are asking whether the process is running under Terminal Services
> or
[quoted text clipped - 15 lines]
>
> Thanks
Siva M - 08 Sep 2006 18:53 GMT
Hello,

Its easy to use the same API from .NET
http://www.pinvoke.net/default.aspx/wtsapi32.WTSQuerySessionInformation

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,

> If you are asking whether the process is running under Terminal Services
> or
[quoted text clipped - 15 lines]
>
> Thanks
Ahmed Perlom - 08 Sep 2006 19:27 GMT
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

> Hello,
>
[quoted text clipped - 35 lines]
>>
>> Thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.