Yeah! Figured out how to get informed about the windows system shutdown/user logged off in .NET. With the knowledge of my VB6 days (there we get the info as a parameter in the window close event) my research goes completely to the wrong direction and a search via google does not point to a similar solution for .NET.
The may be simplest code to use is this:
public class Form1: System.Windows.Forms.Form { // Constant value was found in the "winuser.h" header file. private const int WM_ENDSESSION = 0x0016; ... protected override void WndProc(ref Message m) { switch (m.Msg) { case WM_ENDSESSION: // Save settings, state whatever here... MessageBox.Show("WM_ENDSESSION received."); Application.Exit(); // exit the normal way break; // never reached } base.WndProc(ref m); } ... }
© Copyright 2002-2012, Torsten Rendelmann Page rendered at Wednesday, February 08, 2012 7:25:14 AM (W. Europe Standard Time, UTC+01:00)
Like RSS Bandit? Make a donation to help support its development and maintenance. As little as 1€ will help.
SUBSCRIBE RSS GeoURL
newtelligence dasBlog 2.3.9074.18820
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.