Solved

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

Posted on 2008-10-15
3
2,278 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
[X]
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
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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