Solved

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

Posted on 2008-10-15
3
2,202 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now