-
March 31st, 2008, 12:54 PM
#1
Does anyone know how to capture PC locked events?
I've tried looking at SystemEvents but I don't see anything that has to do with capturing an event if the user locks the PC. Does such an event handler exist in C#?
Thanks
-
March 31st, 2008, 01:38 PM
#2
Re: Does anyone know how to capture PC locked events?
Looks like it:
Code:
using System;
using Microsoft.Win32;
public class App
{
static void Main()
{
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
Console.ReadLine(); // block main thread
// !! detach the eventhandler when the application terminates, or you will
leak a handle.
SystemEvents.SessionSwitch -= SystemEvents_SessionSwitch;
}
static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
if(e.Reason == SessionSwitchReason.SessionLock)
{...}
}
}
}
http://bytes.com/forum/thread536508.html
-
March 31st, 2008, 03:34 PM
#3
Re: Does anyone know how to capture PC locked events?
Originally Posted by dglienna
Looks like it:
Code:
using System;
using Microsoft.Win32;
public class App
{
static void Main()
{
SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;
Console.ReadLine(); // block main thread
// !! detach the eventhandler when the application terminates, or you will
leak a handle.
SystemEvents.SessionSwitch -= SystemEvents_SessionSwitch;
}
static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
{
if(e.Reason == SessionSwitchReason.SessionLock)
{...}
}
}
}
http://bytes.com/forum/thread536508.html
Awesome! Thank you, I cannot believe the answer was right under my nose. Still having some problems with this as the events do not get generated but I'm taking a look at the website link you gave for more clues. I think I'll find an answer soon. Thank you!
-
October 13th, 2008, 02:24 PM
#4
Re: Does anyone know how to capture PC locked events?
Did you every solve your issue of not capturing the events. I am having the same issue.
It has been a long day so I might be missing something. I will take another look in the morning.
Last edited by cewolcott; October 13th, 2008 at 02:28 PM.
-
June 13th, 2011, 05:15 AM
#5
Re: Does anyone know how to capture PC locked events?
Windows service not able to capture Login/Lock/Unlock in Win7.
if any one knows the solution or any idea or approach, please help me out.
waiting for all of your positive response.
Thanks in Advance..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|