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 10:08:40 PM (W. Europe Standard Time, UTC+01:00)    #  Comments [0]  | 
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!
On this page....
<June 2003>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

SUBSCRIBE RSS GeoURL e-mail

Search
Categories
Blogroll
[Feed] Dare Obasanjo
Dare Obasanjo aka Carnage4Life
[Feed] Clemens Vasters
[Feed] Omar Shahine
[Feed] Tom Mertens

newtelligence dasBlog 2.1.8102.813

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

WOT Notar

Join WebHost4Life.com