torsten's .NET blog In the end, everything is a gag [Ch. Chaplin]
# Tuesday, June 24, 2003
good old VB6

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);
  }
  ...
}

Technorati tags:
Tuesday, June 24, 2003 11:08:40 PM (W. Europe Daylight Time, UTC+02:00)    #  Comments [0]  | 
Comments are closed.
Navigation

Like RSS Bandit? Make a donation to help support its development and maintenance. As little as 1€ will help.

Make payments with PayPal - it's fast, free and secure!
Site supporters
On this page....
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910

SUBSCRIBE RSS GeoURL e-mail

Search
Categories
Blogroll

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.

Join WebHost4Life.com