Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
0
Answer
Best way to capture windows logging off in application
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Jeff Lee
17y
1.8k
1
Reply
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
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
Simple function to replace complicated Threads?
Catching SMTP Reponse codes