TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jeff Lee
NA
1
0
Best way to capture windows logging off in application
Jul 13 2007 6:38 AM
I have a form application that runs in the taskbar. It is an audit trail application that captures all directory activity on a selected directory. I can get everything I want except users logging off of the computer (either logoff or shutdown). I believe the way to do it is through the session ending event handler. But I can't seem to get any activity in the program when Windows logs off. It just simply closes the program.
To attempt to capture the event, I placed a line in the Form1_Load
SystemEvents
.SessionEnding +=
new
SessionEndingEventHandler
(SystemEvents_SessionEnding);
I then create a method like
private
void
SystemEvents_SessionEnding(
object
sender,
SessionEndingEventArgs
e)
{
MessageBox.Show("Closing Form");
}
*Actually my code is much longer, but that is not so relevant here. I have the method write an event to an xml file.
Why doesn't this work (other than it's Windows)? Or is there a better method of capturing a user logging off windows?
Note: I don't want to capture users closing the program because they can't close the program. It's supposed to monitor file activity. This is for a regulated computer system.
Thanks
Jeff
IT by necessity
Reply
Answers (
0
)
Simple function to replace complicated Threads?
Catching SMTP Reponse codes