Solved

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

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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