How to detect ATX Power-Button Event
C#
1
Posts
1
Posters
0
Views
1
Watching
-
Hi I use Windows-XP/Embedded and I want to shut down my application properly if the user presses the Power-Button. The system is powered by an ATX power supply. I used the following code to test it:
using Microsoft.Win32; ... SystemEvents.PowerModeChanged +=new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged); ... private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) { System.Windows.Forms.MessageBox.Show("Power Off!!!!!!!!!!!!!!!!!!"); }
Unfortunately the message never appears if I click the main button. The only thing that happens is that the top most form/dialog is closed. Is here anything wrong or are there better solutions? Thanks and best regards, Martin