protected override void WndProc(ref Message m) { if (m.Msg == 0x11) // WM_QUERYENDSESSION { MainWindow.SystemShutdown = true; } SoundPlayer.CloseSound(m); base.WndProc(ref m); }