C# shutdown event
C#
3
Posts
2
Posters
0
Views
1
Watching
-
I need to run a cleanup routine before system shutdown. How can I catch the system shutdown event in my C# application? Martin
Look at the
SystemEvents
class. -
Look at the
SystemEvents
class.I found another way to do it. protected override void WndProc(ref System.Windows.Forms.Message m) { // defined in winuser.h const int WM_QUERYENDSESSION = 0x0011; switch(m.Msg) { case WM_QUERYENDSESSION: ////////////////// // cleanup section // ////////////////// base.WndProc(ref m); break; default: base.WndProc(ref m); break; } } Thank you "the last free name" for your suggestion!:)