Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Capture Terminal Session Lock and Unlock events in C# Windows Service

Posted on 2008-10-15
3
2,250 Views
Last Modified: 2013-12-17
I need to create a Windows Service that will capture when a user locks and unlocks their desktop session.  Also, I need to capture the username.  I know how to do this using a regular application, just not a Windows Service.
0
Comment
Question by:fcti
  • 2
3 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22727675
have a look at the following ee link - i think it might be helpful
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22518173.html
0
 

Author Comment

by:fcti
ID: 22727698
Sorry Ragi, that solution won't apply, its for a Windows Application, not a Service.  It relies on WndProc.
0
 

Accepted Solution

by:
fcti earned 0 total points
ID: 22735758
Found the solution.  I am overriding the following event in my service:


protected override void OnSessionChange(SessionChangeDescription changeDescription)
{
switch (changeDescription.Reason)
            {
                case SessionChangeReason.SessionLogon:
                    //Logon
                    break;
                case SessionChangeReason.SessionLogoff:
                    //Logoff
                    break;
                case SessionChangeReason.RemoteConnect:
                    //Remote Connect
                    break;
                case SessionChangeReason.RemoteDisconnect:
                    //Remote Disconnect
                    break;
                case SessionChangeReason.SessionLock:
                    //lock
                    break;
                case SessionChangeReason.SessionUnlock:
                    //Unlock
                    break;
                default:
                    break;
            }
}

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question